|
4 | 4 | *--------------------------------------------------------------------------------------------*/
|
5 | 5 |
|
6 | 6 | import { Dimension, h } from 'vs/base/browser/dom';
|
7 |
| -import { MutableDisposable } from 'vs/base/common/lifecycle'; |
| 7 | +import { DisposableStore, MutableDisposable } from 'vs/base/common/lifecycle'; |
8 | 8 | import { assertType } from 'vs/base/common/types';
|
9 | 9 | import { ICodeEditor, IDiffEditor } from 'vs/editor/browser/editorBrowser';
|
10 | 10 | import { EmbeddedCodeEditorWidget, EmbeddedDiffEditorWidget } from 'vs/editor/browser/widget/embeddedCodeEditorWidget';
|
@@ -38,6 +38,7 @@ export class InteractiveEditorLivePreviewWidget extends ZoneWidget {
|
38 | 38 |
|
39 | 39 | private readonly _elements = h('div.interactive-editor-diff-widget@domNode');
|
40 | 40 |
|
| 41 | + private readonly _sessionStore = this._disposables.add(new DisposableStore()); |
41 | 42 | private readonly _diffEditor: IDiffEditor;
|
42 | 43 | private readonly _inlineDiffDecorations: IEditorDecorationsCollection;
|
43 | 44 | private _dim: Dimension | undefined;
|
@@ -129,6 +130,20 @@ export class InteractiveEditorLivePreviewWidget extends ZoneWidget {
|
129 | 130 |
|
130 | 131 | override show(): void {
|
131 | 132 | assertType(this.editor.hasModel());
|
| 133 | + this._sessionStore.clear(); |
| 134 | + |
| 135 | + this._sessionStore.add(this._diffEditor.onDidUpdateDiff(() => { |
| 136 | + const result = this._diffEditor.getDiffComputationResult(); |
| 137 | + const hasFocus = this._diffEditor.hasTextFocus(); |
| 138 | + this._updateFromChanges(this._session.wholeRange, result?.changes2 ?? []); |
| 139 | + // TODO@jrieken find a better fix for this. this is the challenge: |
| 140 | + // the _doShowForChanges method invokes show of the zone widget which removes and adds the |
| 141 | + // zone and overlay parts. this dettaches and reattaches the dom nodes which means they lose |
| 142 | + // focus |
| 143 | + if (hasFocus) { |
| 144 | + this._diffEditor.focus(); |
| 145 | + } |
| 146 | + })); |
132 | 147 | this._updateFromChanges(this._session.wholeRange, this._session.lastTextModelChanges);
|
133 | 148 | this._isVisible = true;
|
134 | 149 | }
|
|
0 commit comments