monaco-editor icon indicating copy to clipboard operation
monaco-editor copied to clipboard

Add possibility to add view zone inside deleted text zone in inline diff editor

Open chenmy0917 opened this issue 5 years ago • 12 comments

first, create diffEditor this.diffEditor = monaco.editor.createDiffEditor(dom, options);

second, get originalEditor this.originalEditor = this.diffEditor.originalEditor;

third, addViewZone to originalEditor

this.originalEditor.changeViewZones((changeAccessor) => {
    const domNode = doucument.createElement('div');
    changeAccessor.addZone({afterLineNumber: 1, domNode});
})

in Chrom, it can work when i use side-by-side image

but, when i switch to inline-diff, it can't work image

chenmy0917 avatar Sep 15 '20 10:09 chenmy0917

View zones added to the original editor do not render when the diff editor is configured to be rendered inline. But view zones added to the modified editor will render in both cases.

alexdima avatar Sep 17 '20 11:09 alexdima

Please ask your question on StackOverflow. We have a great community over there. They have already answered hundreds of questions and are happy to answer yours as well. You can also try searching through existing issues, looking at API usage samples or at integration samples. See also our issue reporting guidelines.

Happy Coding!

vscodebot[bot] avatar Sep 17 '20 11:09 vscodebot[bot]

Thank you for your answer. What should I do if I want to implement this feature? I am going to modify the source code, can you give me some suggestions? @alexdima

chenmy0917 avatar Sep 22 '20 06:09 chenmy0917

View zones added to the original editor do not render when the diff editor is configured to be rendered inline. But view zones added to the modified editor will render in both cases.

You can use this.diffEditor.modifiedEditor

alexdima avatar Sep 22 '20 09:09 alexdima

View zones added to the original editor do not render when the diff editor is configured to be rendered inline. But view zones added to the modified editor will render in both cases.

You can use this.diffEditor.modifiedEditor

thanks for your answer! @alexdima

The feature I want to achieve is shown in the figure: image

in inline-diff, removed line as view-zone(class named 'view-lines line-delete') render on modifiedEditor, like the figure: image in the case, removed line number is 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 I want add custom dom under the line No.2, and the dom don't cover line No.3

'removed line number is 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16(class named 'view-lines line-delete')' is a viewZone added to modifiedEditor, i can add another viewZone to modifiedEditor, it can be render under line No.16 or above line No.1, like the figure: image

but can't render under line No.2, like first figure

chenmy0917 avatar Sep 22 '20 10:09 chenmy0917

That is currently not possible. It is not possible to insert a view zone inside a deleted zone of text when the diff editor is rendered inline.

alexdima avatar Sep 22 '20 10:09 alexdima

@alexdima I thought of a very unsightly method: step 1: assuming the height of removed-line-view-zone(the dom that class named 'view-lines line-delete') is 100px step 2: assuming the height of my customized view-zone is 50px step 3: add a view zone to modifiedEditor, set heightInPx to 50px, like the figure: image

step 4: create a dom and set height to 150px, set innerHTML to the dom, make it look like the picture below: image

step5: append the dom to my customized view-zone, it will render like the figure: image

you can find, the modifiedEditor is blocked by the dom about step5

step 6: translate the dom up by 100px, like the figure: image

chenmy0917 avatar Sep 22 '20 11:09 chenmy0917

Wanted to know if it's ok to do that and what would be the best way to do that? Looking forward to your reply, thanks🥳 @alexdima

chenmy0917 avatar Sep 22 '20 11:09 chenmy0917

Wanted to know if it's ok to do that and what would be the best way to do that? Looking forward to your reply, thanks🥳 @alexdima

can't😩 because I can’t insert the zone where I want image

chenmy0917 avatar Oct 14 '20 08:10 chenmy0917

Hello @alexdima, I'm willing to work on fixing this issue or to allow this behavior if some guidance is given, more or less, how much effort do you think this takes?

It's an inconsistency with how the split/unified view works and I'd like to help.

miamagana avatar Feb 09 '24 12:02 miamagana

@alexdima Hey Alexandru! Following up on my colleagues message above, we're really eager to resolve this issue. We'd really appreciate your guidance here. Thanks!

sami-lujan-cs avatar Feb 22 '24 22:02 sami-lujan-cs