Unable to preserve current model of modified DiffEditor
See original GitHub issueDescribe the bug We have a use-case, similar to Azure DevOps above, where we allow the user to flip between the normal Editor and the DiffEditor.
This mostly works great except that when switching from the DiffEditor to the Editor, we are unable to use the DiffEditor’s modified model as the model of the Editor. In the flip scenario, switching from the Editor to the DiffEditor, we can do this because of the keepCurrentModel
prop allowed on the Editor, but it seems that the DiffEditor is lacking this ability.
We could benefit from one of two things:
- Advice/Examples on how to implement this pattern.
- A
keepCurrentModifiedModel
prop (or something similar) for the DiffEditor that allows the consumer to prevent the modified model from being disposed on unmount.
To Reproduce
Our setup is similar to below. We keep a ref for the current model and set that ref in the onMount
function of each editor.
const isDiff = React.useState(false);
const model = React.useRef<monaco.editor.ITextModel>();
return {isDiff ?
<DiffEditor
onMount={diffEditor =>
model.current && diffEditor.setModel({ original: diffEditor.getModel().original, modified: model.current });
model.current = diffEditor.getModel().modified;
/> :
<Editor
keepCurrentModel
onMount={editor =>
// model.current && editor.setModel(model.current); <--- ERROR because at this point the DiffEditor's model is disposed!
model.current = editor.getModel();
/>;
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Get the value of Monaco Editor - Stack Overflow
I've got it up and running in the browser, but still can't figure out how to get the current text of the editor,...
Read more >Option to reverse split diff layout (original on right, modified on ...
I've worked around this by overriding the CSS for the inserted/deleted background colours so that deletions show up as green and insertions show ......
Read more >User and Workspace Settings - Visual Studio Code
VS Code says "Unable to write settings." If you try to change a setting (for example turning on Auto Save or selecting a...
Read more >Diffusion-based semantic image editing with mask guidance
In this article, we propose DiffEdit, a method to take advantage of text-conditioned diffusion models for the task of semantic image editing, ...
Read more >Basic Usage (diff editor) - PrimeFaces Extensions Showcase
Called when a for the modified editor model needs to retrieved or created. The options contains value (current value that should be set...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@dehoward done
check the version -
v4.1.3
Thank you for your support!
https://github.com/suren-atoyan/monaco-react/pull/235