Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Highlight merge conflicts in monaco like in VSCode #1529

Closed
Symbolk opened this issue Aug 4, 2019 · 1 comment
Closed

Highlight merge conflicts in monaco like in VSCode #1529

Symbolk opened this issue Aug 4, 2019 · 1 comment

Comments

@Symbolk
Copy link

Symbolk commented Aug 4, 2019

I am integrating the monaco-editor into an Electron app for three-way merge, so I want to highlight merge conflict blocks in VSCode style. Since VSCode itself is based on monaco, I think it is feasible.

monaco-editor version: 0.17.1
**Browser:**Chromium
OS: Windows10

The screenshot of the tool:

image

The expected result:
image

I check the API doc and find a related one that might be useful: colorizeModelLine(model: ITextModel, lineNumber: number, tabSize?: number): string., but I still do not know how to do that because examples are absent. Can anyone give me a hint?

@Symbolk
Copy link
Author

Symbolk commented Aug 6, 2019

I have managed to achieve this by 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:

image

Complete code at: https://github.com/Symbolk/IntelliMerge-UI

@Symbolk Symbolk closed this as completed Aug 6, 2019
@vscodebot vscodebot bot locked and limited conversation to collaborators Oct 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant