简体   繁体   English

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

[英]How to highlight merge conflict blocks in monaco-editor like VSCode?

VSCode has a good feature to highlight merge conflict blocks in this way: VSCode 有一个很好的功能,可以通过这种方式突出显示合并冲突块: VSCode 合并冲突

So I wonder how to achieve that in monaco-editor?所以我想知道如何在 monaco-editor 中实现这一目标?

I checked the API and found a related one: colorizeModelLine(model: ITextModel, lineNumber: number, tabSize?: number): string .我检查了 API 并找到了一个相关的: colorizeModelLine(model: ITextModel, lineNumber: number, tabSize?: number): string

I have managed to achieve this with the following code:我已经设法通过以下代码实现了这一点:

 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'
            }
          }]
      )

It looks like this:它看起来像这样:

在此处输入图片说明

The complete code can be found at: https://github.com/Symbolk/IntelliMerge-UI完整代码可在以下位置找到: https : //github.com/Symbolk/IntelliMerge-UI

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM