Skip to content

Commit 929a64a

Browse files
authored
Fixes scrolling bug in merge editor (microsoft#158721)
1 parent 235a92a commit 929a64a

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

src/vs/workbench/contrib/mergeEditor/browser/view/mergeEditor.ts

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -165,16 +165,7 @@ export class MergeEditor extends AbstractTextEditor<IMergeEditorViewState> {
165165
this._store.add(
166166
this.inputResultView.editor.onDidScrollChange(
167167
reentrancyBarrier.makeExclusive((c) => {
168-
if (c.scrollTopChanged) {
169-
const mapping1 = this.model?.input1ResultMapping.get();
170-
synchronizeScrolling(this.inputResultView.editor, this.input1View.editor, mapping1, MappingDirection.output);
171-
const mapping2 = this.model?.input2ResultMapping.get();
172-
synchronizeScrolling(this.inputResultView.editor, this.input2View.editor, mapping2, MappingDirection.output);
173-
}
174-
if (c.scrollLeftChanged) {
175-
this.input1View.editor.setScrollLeft(c.scrollLeft, ScrollType.Immediate);
176-
this.input2View.editor.setScrollLeft(c.scrollLeft, ScrollType.Immediate);
177-
}
168+
this.updateResultScrolling(c.scrollTopChanged, c.scrollLeftChanged);
178169
})
179170
)
180171
);
@@ -201,6 +192,19 @@ export class MergeEditor extends AbstractTextEditor<IMergeEditorViewState> {
201192
toolbarMenuRender();
202193
}
203194

195+
private updateResultScrolling(scrollTopChanged: boolean, scrollLeftChanged: boolean): void {
196+
if (scrollTopChanged) {
197+
const mapping1 = this.model?.input1ResultMapping.get();
198+
synchronizeScrolling(this.inputResultView.editor, this.input1View.editor, mapping1, MappingDirection.output);
199+
const mapping2 = this.model?.input2ResultMapping.get();
200+
synchronizeScrolling(this.inputResultView.editor, this.input2View.editor, mapping2, MappingDirection.output);
201+
}
202+
if (scrollLeftChanged) {
203+
this.input1View.editor.setScrollLeft(this.inputResultView.editor.getScrollLeft(), ScrollType.Immediate);
204+
this.input2View.editor.setScrollLeft(this.inputResultView.editor.getScrollLeft(), ScrollType.Immediate);
205+
}
206+
}
207+
204208
public get viewModel(): IObservable<MergeEditorViewModel | undefined> {
205209
return this.input1View.viewModel;
206210
}
@@ -391,6 +395,7 @@ export class MergeEditor extends AbstractTextEditor<IMergeEditorViewState> {
391395
}));
392396
mirrorWordWrapTransientState();
393397

398+
this.updateResultScrolling(true, true);
394399

395400
// detect when base, input1, and input2 become empty and replace THIS editor with its result editor
396401
// TODO@jrieken@hediet this needs a better/cleaner solution

0 commit comments

Comments
 (0)