monaco-react
monaco-react copied to clipboard
Wordwrap in diff editor doesn't work in original pane
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:
- create a diff editor with word wrap set to on
- enter long text
- 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
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'}} />)
}
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.
could be related to https://github.com/microsoft/monaco-editor/issues/3346
Surprisingly, version 4.7.0-rc.0 works for me, but version 4.7.0 does not.
This comment solves my problem.
https://github.com/microsoft/monaco-editor/discussions/4454#discussioncomment-11111244
This issue has been marked as stale due to inactivity. It will be closed in 7 days unless further activity occurs.
Closing due to inactivity. Feel free to reopen if needed.