Skip to content

Commit

Permalink
Improves merge editor dev commands (#157706)
Browse files Browse the repository at this point in the history
* Improves merge editor dev commands

* Fixes layering issues.
  • Loading branch information
hediet authored and joyceerhl committed Aug 10, 2022
1 parent b936110 commit f926f3a
Show file tree
Hide file tree
Showing 7 changed files with 322 additions and 181 deletions.
163 changes: 0 additions & 163 deletions src/vs/workbench/contrib/mergeEditor/browser/commands/devCommands.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { EditorPaneDescriptor, IEditorPaneRegistry } from 'vs/workbench/browser/
import { Extensions as WorkbenchExtensions, IWorkbenchContributionsRegistry } from 'vs/workbench/common/contributions';
import { EditorExtensions, IEditorFactoryRegistry } from 'vs/workbench/common/editor';
import { AcceptAllInput1, AcceptAllInput2, CompareInput1WithBaseCommand, CompareInput2WithBaseCommand, GoToNextConflict, GoToPreviousConflict, OpenBaseFile, OpenMergeEditor, OpenResultResource, SetColumnLayout, SetMixedLayout, ToggleActiveConflictInput1, ToggleActiveConflictInput2 } from 'vs/workbench/contrib/mergeEditor/browser/commands/commands';
import { MergeEditorCopyContentsToJSON, MergeEditorOpenContents } from 'vs/workbench/contrib/mergeEditor/browser/commands/devCommands';
import { MergeEditorInput } from 'vs/workbench/contrib/mergeEditor/browser/mergeEditorInput';
import { MergeEditor, MergeEditorResolverContribution, MergeEditorOpenHandlerContribution } from 'vs/workbench/contrib/mergeEditor/browser/view/mergeEditor';
import { LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle';
Expand Down Expand Up @@ -54,9 +53,6 @@ registerAction2(SetColumnLayout);
registerAction2(OpenMergeEditor);
registerAction2(OpenBaseFile);

registerAction2(MergeEditorCopyContentsToJSON);
registerAction2(MergeEditorOpenContents);

registerAction2(GoToNextConflict);
registerAction2(GoToPreviousConflict);

Expand Down
14 changes: 1 addition & 13 deletions src/vs/workbench/contrib/mergeEditor/browser/mergeEditorInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ class MergeEditorCloseHandler implements IEditorCloseHandler {
} else if (choice === 1) {
// discard: undo all changes and save original (pre-merge) state
for (const input of handler) {
input._discardMergeChanges();
input._model.discardMergeChanges();
}
return ConfirmResult.SAVE;

Expand All @@ -268,16 +268,4 @@ class MergeEditorCloseHandler implements IEditorCloseHandler {
return ConfirmResult.DONT_SAVE;
}
}

private _discardMergeChanges(): void {
const chunks: string[] = [];
while (true) {
const chunk = this._model.resultSnapshot.read();
if (chunk === null) {
break;
}
chunks.push(chunk);
}
this._model.result.setValue(chunks.join());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,23 @@ export class MergeEditorModel extends EditorModel {
);
});

readonly resultSnapshot: ITextSnapshot;
private readonly resultSnapshot: ITextSnapshot;

public getInitialResultValue(): string {
const chunks: string[] = [];
while (true) {
const chunk = this.resultSnapshot.read();
if (chunk === null) {
break;
}
chunks.push(chunk);
}
return chunks.join();
}

public discardMergeChanges(): void {
this.result.setValue(this.getInitialResultValue());
}

constructor(
readonly base: ITextModel,
Expand Down
Loading

0 comments on commit f926f3a

Please sign in to comment.