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

Fix issues with inconsistent line wrap application #174688

Merged
merged 1 commit into from
Feb 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/vs/editor/browser/services/abstractCodeEditorService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,11 @@ export abstract class AbstractCodeEditorService extends Disposable implements IC
this._transientWatchers[uri] = w;
}

w.set(key, value);
this._onDidChangeTransientModelProperty.fire(model);
const previousValue = w.get(key);
if (previousValue !== value) {
w.set(key, value);
this._onDidChangeTransientModelProperty.fire(model);
}
}

public getTransientModelProperty(model: ITextModel, key: string): any {
Expand Down
24 changes: 15 additions & 9 deletions src/vs/workbench/contrib/mergeEditor/browser/view/mergeEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { ICodeEditor, IViewZoneChangeAccessor } from 'vs/editor/browser/editorBr
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
import { IEditorOptions as ICodeEditorOptions } from 'vs/editor/common/config/editorOptions';
import { ICodeEditorViewState, ScrollType } from 'vs/editor/common/editorCommon';
import { ITextModel } from 'vs/editor/common/model';
import { ITextResourceConfigurationService } from 'vs/editor/common/services/textResourceConfiguration';
import { localize } from 'vs/nls';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
Expand Down Expand Up @@ -173,7 +174,7 @@ export class MergeEditor extends AbstractTextEditor<IMergeEditorViewState> {

this.input1View.updateOptions(inputOptions);
this.input2View.updateOptions(inputOptions);
this.baseViewOptions.set(this.input2View.editor.getRawOptions(), undefined);
this.baseViewOptions.set({ ...this.input2View.editor.getRawOptions() }, undefined);
this.inputResultView.updateOptions(options);
}

Expand Down Expand Up @@ -302,17 +303,22 @@ export class MergeEditor extends AbstractTextEditor<IMergeEditorViewState> {
}

// word wrap special case - sync transient state from result model to input[1|2] models
const mirrorWordWrapTransientState = () => {
const state = readTransientState(model.resultTextModel, this._codeEditorService);
writeTransientState(model.input2.textModel, state, this._codeEditorService);
writeTransientState(model.input1.textModel, state, this._codeEditorService);
const mirrorWordWrapTransientState = (candidate: ITextModel) => {
const candidateState = readTransientState(candidate, this._codeEditorService);

writeTransientState(model.input2.textModel, candidateState, this._codeEditorService);
writeTransientState(model.input1.textModel, candidateState, this._codeEditorService);
writeTransientState(model.resultTextModel, candidateState, this._codeEditorService);

const baseTextModel = this.baseView.get()?.editor.getModel();
if (baseTextModel) {
writeTransientState(baseTextModel, candidateState, this._codeEditorService);
}
};
this._sessionDisposables.add(this._codeEditorService.onDidChangeTransientModelProperty(candidate => {
if (candidate === this.inputResultView.editor.getModel()) {
mirrorWordWrapTransientState();
}
mirrorWordWrapTransientState(candidate);
}));
mirrorWordWrapTransientState();
mirrorWordWrapTransientState(this.inputResultView.editor.getModel()!);

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