Add more kinds of underline colour

Viewed 235

I'm using Monaco Editor to make my own IDE. I use provideHover to underline certain kinds of code. It seems that different DiagnosticCategory or MarkerSeverity have impact to the colour of the underline. At the moment, it seems that there are only 4 kinds of underline colours.

/* Diagnostics */
enum DiagnosticCategory {
    Warning = 0,
    Error = 1,
    Suggestion = 2,
    Message = 3
}

Does anyone know how to add more kinds of underline colour?

1 Answers

The shape and colour of the underline is determined by its CSS class, e.g. squiggly-error:

enter image description here

The constants for corresponding CSS classes are declared in intervalTree.ts within VS Code project:

export const enum ClassName {
    EditorHintDecoration = 'squiggly-hint',
    EditorInfoDecoration = 'squiggly-info',
    EditorWarningDecoration = 'squiggly-warning',
    EditorErrorDecoration = 'squiggly-error',
    EditorUnnecessaryDecoration = 'squiggly-unnecessary',
    EditorUnnecessaryInlineDecoration = 'squiggly-inline-unnecessary',
    EditorDeprecatedInlineDecoration = 'squiggly-inline-deprecated'
}

The code using these constants is located in markerDecorationsServiceImpl.ts (in a switch based on MarkerSeverity).


It doesn't seem to be designed to be extendable by configuration. Adding another underline type would probably require changes in vs core classes.
Related