添加更多种类的下划线颜色

Sof*_*mur 5 monaco-editor

我正在使用 Monaco Editor 来制作我自己的 IDE。我习惯provideHover在某些类型的代码下划线。看起来下划线的颜色不同DiagnosticCategory或有影响。MarkerSeverity目前好像只有4种下划线颜色。

/* Diagnostics */
enum DiagnosticCategory {
    Warning = 0,
    Error = 1,
    Suggestion = 2,
    Message = 3
}
Run Code Online (Sandbox Code Playgroud)

有谁知道如何添加更多种类的下划线颜色?

col*_*der 1

下划线的形状和颜色由其 CSS 类决定,例如squiggly-error

在此输入图像描述

相应 CSS 类的常量在VS Code 项目内的IntervalTree.ts中声明:

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'
}
Run Code Online (Sandbox Code Playgroud)

使用这些常量的代码位于markerDecorationsServiceImpl.ts(基于 的开关中MarkerSeverity)。


它似乎没有被设计为可通过配置进行扩展。添加另一种下划线类型可能需要更改核心类。