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

Wordwrap in diff editor doesn't work in original pane

Open shubhendusaurabh opened this issue 9 months ago • 3 comments

Describe the bug Wordwrap doesn't work in original pane in diff editor component while it works in modified pane when using any monaco editor with version >= 0.44

This happens when using <DiffEditor /> component. Using loader and creating monaco instance using js works well.

To Reproduce

Steps to reproduce the behavior:

  1. create a diff editor with word wrap set to on
  2. enter long text
  3. observe word wrap works in modified pane but doesn't in original pane.
import { DiffEditor, loader } from "@monaco-editor/react";
loader.config({ paths: { vs: 'https://cdn.jsdelivr.net/npm/[email protected]/min/vs' } });

  const original= `The quick brown fox jumps over the lazy dog. \nThis is a classic pangram, containing every letter of the alphabet. \n It's often used for testing typewriters and computer keyboards.  \nThe sentence is simple, yet demonstrates the full range of characters.  Furthermore, it's easily memorable.`;
  const modified= `The quick, brown fox jumps over the lazy, sleeping dog. \nThis is a slightly modified pangram, still containing every letter of the alphabet.\nIt's often used for testing typewriters and computer keyboards. \nThe sentence is simple and memorable , while demonstrating the full range of characters, including punctuation.`
  
function App() {
  return (
    <DiffEditor
      height="100vh"
      original={original}
      modified={modified}
      options={{
        wordWrap: "on",
      }}
    />
  );
}

export default App;

Expected behavior

Word wrap should work in original pane as well.

Screenshots

Image

Desktop (please complete the following information):

  • OS: Linux
  • Browser: Firefox, Chrome
  • Version: latest

Additional context

Creating monaco instance using loader works correctly


import { DiffEditor, loader } from "@monaco-editor/react";
loader.config({ paths: { vs: 'https://cdn.jsdelivr.net/npm/[email protected]/min/vs' } });

function App() {

  loader.init().then(monaco => {
    const differ = monaco.editor.createDiffEditor(
      document.getElementById('diff'),
      {
        wordWrap: 'on'
      }
    );

    const o = monaco.editor.createModel(original)
    const m = monaco.editor.createModel(modified)
  
    differ.setModel({
      original: o, modified: m
    })
  })
  return (<div id="diff" style={{height: '100vh'}} />)
}

Image

https://github.com/microsoft/monaco-editor/blob/main/CHANGELOG.md#0440 Monaco stated using new diff editor implementation from 0.44, so it could be related to that.

shubhendusaurabh avatar Feb 13 '25 18:02 shubhendusaurabh

could be related to https://github.com/microsoft/monaco-editor/issues/3346

shubhendusaurabh avatar Feb 22 '25 12:02 shubhendusaurabh

Surprisingly, version 4.7.0-rc.0 works for me, but version 4.7.0 does not.

AuroraDysis avatar Apr 16 '25 15:04 AuroraDysis

This comment solves my problem.

https://github.com/microsoft/monaco-editor/discussions/4454#discussioncomment-11111244

AuroraDysis avatar May 02 '25 01:05 AuroraDysis

This issue has been marked as stale due to inactivity. It will be closed in 7 days unless further activity occurs.

github-actions[bot] avatar Oct 30 '25 00:10 github-actions[bot]

Closing due to inactivity. Feel free to reopen if needed.

github-actions[bot] avatar Nov 07 '25 00:11 github-actions[bot]