Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Diff markers lost when diff editor hidden #15178

Open
Tracked by #15068
colin-grant-work opened this issue Mar 12, 2025 · 3 comments · May be fixed by #15189
Open
Tracked by #15068

Diff markers lost when diff editor hidden #15178

colin-grant-work opened this issue Mar 12, 2025 · 3 comments · May be fixed by #15189
Assignees

Comments

@colin-grant-work
Copy link
Contributor

When a diff editor is hidden and shown again, the diff highlights disappear from the modified (right) side. It may have to do with @tsmaeder's recent changes to set and unset the model when an editor is hidden.

To reproduce

  1. Open a diff editor (e.g. make a change and then use the SCM view, or compare two files)
  2. Hide the diff editor (e.g. open another editor, or the settings widget)
  3. Reveal the editor.
  4. Observe that there are no diff highlights on the right side.

A possibly related issue is that if a diff editor is hidden when changes affecting its display are made - e.g. toggling word wrapping - an error is thrown that points to this Monaco code:

https://github.com/microsoft/vscode/blob/c2261b02faf97df586d23f8b7d2eb75e67bd00ed/src/vs/editor/browser/widget/diffEditor/components/diffEditorViewZones/diffEditorViewZones.ts#L601

indicating that the non-null assertion has failed: _getViewModel() has returned null.

@JonasHelming
Copy link
Contributor

Thank you for reporting this, could you have a look at a fix?

@tsmaeder
Copy link
Contributor

@colin-grant-work what's the stack trace when you get the error?

@colin-grant-work
Copy link
Contributor Author

colin-grant-work commented Mar 13, 2025

The full stack is below. The part of interest to us is the entry from our code at

updateMonacoDiffEditorOptions (monaco-editor-provider.ts:317)

which kicks off updates on the Monaco side, which through various layers of observables, end up wanting to calculate how the diff regions match up.

getAdditionalLineHeights (diffEditorViewZones.ts:601)
computeRangeAlignment (diffEditorViewZones.ts:466)
(anonymous) (diffEditorViewZones.ts:96)
_recomputeIfNeeded (derived.ts:301)
get (derived.ts:272)
reportChanges (base.ts:188)
get (derived.ts:257)
reportChanges (base.ts:188)
get (derived.ts:257)
reportChanges (base.ts:188)
endUpdate (autorun.ts:265)
endUpdate (derived.ts:374)
endUpdate (derived.ts:374)
endUpdate (derived.ts:374)
finish (base.ts:371)
set (base.ts:444)
(anonymous) (diffEditorViewZones.ts:72)
doRun (async.ts:1064)
onTimeout (async.ts:1059)
setTimeout (async)
schedule (async.ts:1031)
(anonymous) (diffEditorViewZones.ts:78)
_deliver (event.ts:1243)
_deliverQueue (event.ts:1254)
fire (event.ts:1278)
(anonymous) (codeEditorWidget.ts:283)
_deliver (event.ts:1243)
fire (event.ts:1274)
_recomputeOptions (editorConfiguration.ts:112)
updateOptions (editorConfiguration.ts:170)
updateOptions (codeEditorWidget.ts:422)
(anonymous) (diffEditorEditors.ts:76)
_runIfNeeded (autorun.ts:226)
endUpdate (autorun.ts:273)
finish (base.ts:371)
set (base.ts:444)
updateOptions (diffEditorOptions.ts:89)
updateOptions (diffEditorWidget.ts:517)
updateOptions (standaloneCodeEditor.ts:550)
updateMonacoDiffEditorOptions (monaco-editor-provider.ts:317)
(anonymous) (monaco-editor-provider.ts:299)
(anonymous) (event.ts:176)
invoke (event.ts:184)
fire (event.ts:327)
fireChangeEvent (injectable-preference-proxy.ts:261)
handlePreferenceChanges (injectable-preference-proxy.ts:247)
(anonymous) (injectable-preference-proxy.ts:239)
(anonymous) (event.ts:176)
invoke (event.ts:184)
fire (event.ts:327)
reconcilePreferences (preference-service.ts:392)
(anonymous) (preference-service.ts:308)
(anonymous) (event.ts:176)
invoke (event.ts:184)
fire (event.ts:327)
(anonymous) (user-configs-preference-provider.ts:124)
(anonymous) (event.ts:176)
invoke (event.ts:184)
fire (event.ts:327)
(anonymous) (preference-provider.ts:133)
(anonymous) (index.js:21)
setTimeout (async)
(anonymous) (index.js:18)
(anonymous) (index.js:13)
(anonymous) (abstract-resource-preference-provider.ts:127)
await in (anonymous) (async)
(anonymous) (abstract-resource-preference-provider.ts:128)
(anonymous) (event.ts:176)
invoke (event.ts:184)
fire (event.ts:327)
fire (event.ts:397)
conclude (preference-transaction-manager.ts:145)
await in conclude (async)
dispose (preference-transaction-manager.ts:155)
disposable.dispose (disposable.ts:137)
(anonymous) (preference-transaction-manager.ts:131)
Promise.then (async)
disposeWhenDone (preference-transaction-manager.ts:129)
enqueueAction (preference-transaction-manager.ts:110)
await in enqueueAction (async)
doSetPreference (abstract-resource-preference-provider.ts:133)
setPreference (abstract-resource-preference-provider.ts:116)
setWithConfigName (user-configs-preference-provider.ts:105)
setPreference (user-configs-preference-provider.ts:113)
set (preference-service.ts:438)
setPreferenceImmediately (preference-node-renderer.ts:446)
handleUserInteraction (preference-select-input.ts:115)
onChange (preference-select-input.ts:73)
selectOption (select-component.tsx:364)
onMouseDown (select-component.tsx:354)
callCallback (react-dom.development.js:4164)
invokeGuardedCallbackDev (react-dom.development.js:4213)
invokeGuardedCallback (react-dom.development.js:4277)
invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:4291)
executeDispatch (react-dom.development.js:9041)
processDispatchQueueItemsInOrder (react-dom.development.js:9073)
processDispatchQueue (react-dom.development.js:9086)
dispatchEventsForPlugins (react-dom.development.js:9097)
(anonymous) (react-dom.development.js:9288)
batchedUpdates$1 (react-dom.development.js:26179)
batchedUpdates (react-dom.development.js:3991)
dispatchEventForPluginEventSystem (react-dom.development.js:9287)
dispatchEventWithEnableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay (react-dom.development.js:6465)
dispatchEvent (react-dom.development.js:6457)
dispatchDiscreteEvent (react-dom.development.js:6430)

@colin-grant-work colin-grant-work linked a pull request Mar 13, 2025 that will close this issue
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants