mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-20 02:08:47 +00:00
@@ -37,7 +37,7 @@ import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { basename } from 'vs/base/common/resources';
|
||||
import { MenuId, IMenuService, IMenu, MenuItemAction, MenuRegistry } from 'vs/platform/actions/common/actions';
|
||||
import { createAndFillInActionBarActions } from 'vs/platform/actions/browser/menuEntryActionViewItem';
|
||||
import { IEditorModel, ScrollType, IEditorContribution, IDiffEditorModel } from 'vs/editor/common/editorCommon';
|
||||
import { ScrollType, IEditorContribution, IDiffEditorModel, IEditorModel, IEditorDecorationsCollection } from 'vs/editor/common/editorCommon';
|
||||
import { OverviewRulerLane, ITextModel, IModelDecorationOptions, MinimapPosition, shouldSynchronizeModel } from 'vs/editor/common/model';
|
||||
import { equals, sortedDiff } from 'vs/base/common/arrays';
|
||||
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
|
||||
@@ -73,7 +73,7 @@ class DiffActionRunner extends ActionRunner {
|
||||
}
|
||||
|
||||
export interface IModelRegistry {
|
||||
getModel(editorModel: IEditorModel): DirtyDiffModel | undefined;
|
||||
getModel(editorModel: IEditorModel, codeEditor: ICodeEditor): DirtyDiffModel | undefined;
|
||||
}
|
||||
|
||||
export interface DirtyDiffContribution extends IEditorContribution {
|
||||
@@ -593,7 +593,7 @@ export class GotoPreviousChangeAction extends EditorAction {
|
||||
}
|
||||
|
||||
const lineNumber = outerEditor.getPosition().lineNumber;
|
||||
const model = controller.modelRegistry.getModel(outerEditor.getModel());
|
||||
const model = controller.modelRegistry.getModel(outerEditor.getModel(), outerEditor);
|
||||
if (!model || model.changes.length === 0) {
|
||||
return;
|
||||
}
|
||||
@@ -635,7 +635,7 @@ export class GotoNextChangeAction extends EditorAction {
|
||||
}
|
||||
|
||||
const lineNumber = outerEditor.getPosition().lineNumber;
|
||||
const model = controller.modelRegistry.getModel(outerEditor.getModel());
|
||||
const model = controller.modelRegistry.getModel(outerEditor.getModel(), outerEditor);
|
||||
|
||||
if (!model || model.changes.length === 0) {
|
||||
return;
|
||||
@@ -845,7 +845,7 @@ export class DirtyDiffController extends Disposable implements DirtyDiffContribu
|
||||
return false;
|
||||
}
|
||||
|
||||
const model = this.modelRegistry.getModel(editorModel);
|
||||
const model = this.modelRegistry.getModel(editorModel, this.editor);
|
||||
|
||||
if (!model) {
|
||||
return false;
|
||||
@@ -958,7 +958,7 @@ export class DirtyDiffController extends Disposable implements DirtyDiffContribu
|
||||
return;
|
||||
}
|
||||
|
||||
const model = this.modelRegistry.getModel(editorModel);
|
||||
const model = this.modelRegistry.getModel(editorModel, this.editor);
|
||||
|
||||
if (!model) {
|
||||
return;
|
||||
@@ -985,7 +985,7 @@ export class DirtyDiffController extends Disposable implements DirtyDiffContribu
|
||||
return [];
|
||||
}
|
||||
|
||||
const model = this.modelRegistry.getModel(this.editor.getModel());
|
||||
const model = this.modelRegistry.getModel(this.editor.getModel(), this.editor);
|
||||
|
||||
if (!model) {
|
||||
return [];
|
||||
@@ -1080,11 +1080,12 @@ class DirtyDiffDecorator extends Disposable {
|
||||
private modifiedOptions: ModelDecorationOptions;
|
||||
private modifiedPatternOptions: ModelDecorationOptions;
|
||||
private deletedOptions: ModelDecorationOptions;
|
||||
private decorations: string[] = [];
|
||||
private decorationsCollection: IEditorDecorationsCollection | undefined;
|
||||
private editorModel: ITextModel | null;
|
||||
|
||||
constructor(
|
||||
editorModel: ITextModel,
|
||||
private readonly codeEditor: ICodeEditor,
|
||||
private model: DirtyDiffModel,
|
||||
@IConfigurationService private readonly configurationService: IConfigurationService
|
||||
) {
|
||||
@@ -1176,18 +1177,22 @@ class DirtyDiffDecorator extends Disposable {
|
||||
}
|
||||
});
|
||||
|
||||
this.decorations = this.editorModel.deltaDecorations(this.decorations, decorations);
|
||||
if (!this.decorationsCollection) {
|
||||
this.codeEditor.createDecorationsCollection(decorations);
|
||||
} else {
|
||||
this.decorationsCollection.set(decorations);
|
||||
}
|
||||
}
|
||||
|
||||
override dispose(): void {
|
||||
super.dispose();
|
||||
|
||||
if (this.editorModel && !this.editorModel.isDisposed()) {
|
||||
this.editorModel.deltaDecorations(this.decorations, []);
|
||||
if (this.decorationsCollection) {
|
||||
this.decorationsCollection?.clear();
|
||||
}
|
||||
|
||||
this.editorModel = null;
|
||||
this.decorations = [];
|
||||
this.decorationsCollection = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1543,7 +1548,7 @@ export class DirtyDiffWorkbenchController extends Disposable implements ext.IWor
|
||||
|
||||
private enabled = false;
|
||||
private viewState: IViewState = { width: 3, visibility: 'always' };
|
||||
private items = new ResourceMap<DirtyDiffItem>();
|
||||
private items = new ResourceMap<Map<string, DirtyDiffItem>>(); // resource -> editor id -> DirtyDiffItem
|
||||
private readonly transientDisposables = this._register(new DisposableStore());
|
||||
private stylesheet: HTMLStyleElement;
|
||||
|
||||
@@ -1636,7 +1641,7 @@ export class DirtyDiffWorkbenchController extends Disposable implements ext.IWor
|
||||
this.transientDisposables.clear();
|
||||
|
||||
for (const [, dirtyDiff] of this.items) {
|
||||
dirtyDiff.dispose();
|
||||
dispose(dirtyDiff.values());
|
||||
}
|
||||
|
||||
this.items.clear();
|
||||
@@ -1653,13 +1658,16 @@ export class DirtyDiffWorkbenchController extends Disposable implements ext.IWor
|
||||
controller.modelRegistry = this;
|
||||
}
|
||||
|
||||
if (textModel && !this.items.has(textModel.uri)) {
|
||||
if (textModel && (!this.items.has(textModel.uri) || !this.items.get(textModel.uri)!.has(editor.getId()))) {
|
||||
const textFileModel = this.textFileService.files.get(textModel.uri);
|
||||
|
||||
if (textFileModel?.isResolved()) {
|
||||
const dirtyDiffModel = this.instantiationService.createInstance(DirtyDiffModel, textFileModel);
|
||||
const decorator = new DirtyDiffDecorator(textFileModel.textEditorModel, dirtyDiffModel, this.configurationService);
|
||||
this.items.set(textModel.uri, new DirtyDiffItem(dirtyDiffModel, decorator));
|
||||
const decorator = new DirtyDiffDecorator(textFileModel.textEditorModel, editor, dirtyDiffModel, this.configurationService);
|
||||
if (!this.items.has(textModel.uri)) {
|
||||
this.items.set(textModel.uri, new Map());
|
||||
}
|
||||
this.items.get(textModel.uri)?.set(editor.getId(), new DirtyDiffItem(dirtyDiffModel, decorator));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1667,14 +1675,14 @@ export class DirtyDiffWorkbenchController extends Disposable implements ext.IWor
|
||||
|
||||
for (const [uri, item] of this.items) {
|
||||
if (!this.editorService.isOpened({ resource: uri, typeId: FILE_EDITOR_INPUT_ID, editorId: DEFAULT_EDITOR_ASSOCIATION.id })) {
|
||||
item.dispose();
|
||||
dispose(item.values());
|
||||
this.items.delete(uri);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
getModel(editorModel: ITextModel): DirtyDiffModel | undefined {
|
||||
return this.items.get(editorModel.uri)?.model;
|
||||
getModel(editorModel: ITextModel, codeEditor: ICodeEditor): DirtyDiffModel | undefined {
|
||||
return this.items.get(editorModel.uri)?.get(codeEditor.getId())?.model;
|
||||
}
|
||||
|
||||
override dispose(): void {
|
||||
|
||||
Reference in New Issue
Block a user