如何在 VSCode 等摩纳哥编辑器中突出显示合并冲突块?

K. *_*bol 2 git-merge-conflict visual-studio-code monaco-editor

VSCode 有一个很好的功能,可以通过这种方式突出显示合并冲突块: VSCode 合并冲突

所以我想知道如何在 monaco-editor 中实现这一目标?

我检查了 API 并找到了一个相关的:colorizeModelLine(model: ITextModel, lineNumber: number, tabSize?: number): string.

K. *_*bol 6

我已经设法通过以下代码实现了这一点:

 this.editor.deltaDecorations(
        this.editor.getModel().getAllDecorations(),
        [{
            range: new monaco.Range(
              conflictBlock.right_start,
              0,
              conflictBlock.right_end,
              0
            ),
            options: {
              isWholeLine: true,
              className: 'rightLineDecoration',
              marginClassName: 'rightLineDecoration'
            }
          }]
      )

Run Code Online (Sandbox Code Playgroud)

它看起来像这样:

在此处输入图片说明

完整代码可在以下位置找到:https : //github.com/Symbolk/IntelliMerge-UI