提交 b8e43cc7 编写于 作者: J Johannes Rieken

💄

上级 9bc4699d
......@@ -9,7 +9,6 @@ import { toDisposable, DisposableStore, MutableDisposable } from 'vs/base/common
import { StableEditorScrollState } from 'vs/editor/browser/core/editorState';
import * as editorBrowser from 'vs/editor/browser/editorBrowser';
import { registerEditorContribution } from 'vs/editor/browser/editorExtensions';
import { IConfigurationChangedEvent } from 'vs/editor/common/config/editorOptions';
import * as editorCommon from 'vs/editor/common/editorCommon';
import { IModelDecorationsChangeAccessor } from 'vs/editor/common/model';
import { CodeLensProviderRegistry, CodeLens } from 'vs/editor/common/modes';
......@@ -44,8 +43,8 @@ export class CodeLensContribution implements editorCommon.IEditorContribution {
this._globalToDispose.add(this._editor.onDidChangeModel(() => this._onModelChange()));
this._globalToDispose.add(this._editor.onDidChangeModelLanguage(() => this._onModelChange()));
this._globalToDispose.add(this._editor.onDidChangeConfiguration((e: IConfigurationChangedEvent) => {
let prevIsEnabled = this._isEnabled;
this._globalToDispose.add(this._editor.onDidChangeConfiguration(() => {
const prevIsEnabled = this._isEnabled;
this._isEnabled = this._editor.getConfiguration().contribInfo.codeLens;
if (prevIsEnabled !== this._isEnabled) {
this._onModelChange();
......@@ -146,9 +145,9 @@ export class CodeLensContribution implements editorCommon.IEditorContribution {
}, 250);
this._localToDispose.add(scheduler);
this._localToDispose.add(this._detectVisibleLenses);
this._localToDispose.add(this._editor.onDidChangeModelContent((e) => {
this._editor.changeDecorations((changeAccessor) => {
this._editor.changeViewZones((viewAccessor) => {
this._localToDispose.add(this._editor.onDidChangeModelContent(() => {
this._editor.changeDecorations(decorationsAccessor => {
this._editor.changeViewZones(viewZonesAccessor => {
let toDispose: CodeLensWidget[] = [];
let lastLensLineNumber: number = -1;
......@@ -159,17 +158,17 @@ export class CodeLensContribution implements editorCommon.IEditorContribution {
toDispose.push(lens);
} else {
lens.update(viewAccessor);
lens.update(viewZonesAccessor);
lastLensLineNumber = lens.getLineNumber();
}
});
let helper = new CodeLensHelper();
toDispose.forEach((l) => {
l.dispose(helper, viewAccessor);
l.dispose(helper, viewZonesAccessor);
this._lenses.splice(this._lenses.indexOf(l), 1);
});
helper.commit(changeAccessor);
helper.commit(decorationsAccessor);
});
});
......@@ -183,15 +182,15 @@ export class CodeLensContribution implements editorCommon.IEditorContribution {
this._detectVisibleLenses.schedule();
}
}));
this._localToDispose.add(this._editor.onDidLayoutChange(e => {
this._localToDispose.add(this._editor.onDidLayoutChange(() => {
this._detectVisibleLenses.schedule();
}));
this._localToDispose.add(toDisposable(() => {
if (this._editor.getModel()) {
const scrollState = StableEditorScrollState.capture(this._editor);
this._editor.changeDecorations((changeAccessor) => {
this._editor.changeViewZones((accessor) => {
this._disposeAllLenses(changeAccessor, accessor);
this._editor.changeDecorations(decorationsAccessor => {
this._editor.changeViewZones(viewZonesAccessor => {
this._disposeAllLenses(decorationsAccessor, viewZonesAccessor);
});
});
scrollState.restore(this._editor);
......@@ -256,10 +255,12 @@ export class CodeLensContribution implements editorCommon.IEditorContribution {
const scrollState = StableEditorScrollState.capture(this._editor);
this._editor.changeDecorations((changeAccessor) => {
this._editor.changeViewZones((accessor) => {
this._editor.changeDecorations(decorationsAccessor => {
this._editor.changeViewZones(viewZoneAccessor => {
let codeLensIndex = 0, groupsIndex = 0, helper = new CodeLensHelper();
const helper = new CodeLensHelper();
let codeLensIndex = 0;
let groupsIndex = 0;
while (groupsIndex < groups.length && codeLensIndex < this._lenses.length) {
......@@ -267,14 +268,14 @@ export class CodeLensContribution implements editorCommon.IEditorContribution {
let codeLensLineNumber = this._lenses[codeLensIndex].getLineNumber();
if (codeLensLineNumber < symbolsLineNumber) {
this._lenses[codeLensIndex].dispose(helper, accessor);
this._lenses[codeLensIndex].dispose(helper, viewZoneAccessor);
this._lenses.splice(codeLensIndex, 1);
} else if (codeLensLineNumber === symbolsLineNumber) {
this._lenses[codeLensIndex].updateCodeLensSymbols(groups[groupsIndex], helper);
groupsIndex++;
codeLensIndex++;
} else {
this._lenses.splice(codeLensIndex, 0, new CodeLensWidget(groups[groupsIndex], this._editor, helper, accessor, () => this._detectVisibleLenses.schedule()));
this._lenses.splice(codeLensIndex, 0, new CodeLensWidget(groups[groupsIndex], this._editor, helper, viewZoneAccessor, () => this._detectVisibleLenses.schedule()));
codeLensIndex++;
groupsIndex++;
}
......@@ -282,17 +283,17 @@ export class CodeLensContribution implements editorCommon.IEditorContribution {
// Delete extra code lenses
while (codeLensIndex < this._lenses.length) {
this._lenses[codeLensIndex].dispose(helper, accessor);
this._lenses[codeLensIndex].dispose(helper, viewZoneAccessor);
this._lenses.splice(codeLensIndex, 1);
}
// Create extra symbols
while (groupsIndex < groups.length) {
this._lenses.push(new CodeLensWidget(groups[groupsIndex], this._editor, helper, accessor, () => this._detectVisibleLenses.schedule()));
this._lenses.push(new CodeLensWidget(groups[groupsIndex], this._editor, helper, viewZoneAccessor, () => this._detectVisibleLenses.schedule()));
groupsIndex++;
}
helper.commit(changeAccessor);
helper.commit(decorationsAccessor);
});
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册