question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to preserve current model of modified DiffEditor

See original GitHub issue

Describe the bug image 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:

  1. Advice/Examples on how to implement this pattern.
  2. 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:closed
  • Created 2 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
suren-atoyancommented, Apr 21, 2021

@dehoward done

check the version - v4.1.3

Thank you for your support!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found