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

check for disposed lenses before updating them, #85093

上级 4a581d25
...@@ -367,7 +367,7 @@ export class CodeLensContribution implements editorCommon.IEditorContribution { ...@@ -367,7 +367,7 @@ export class CodeLensContribution implements editorCommon.IEditorContribution {
}); });
return Promise.all(promises).then(() => { return Promise.all(promises).then(() => {
if (!token.isCancellationRequested) { if (!token.isCancellationRequested && !lenses[i].isDisposed()) {
lenses[i].updateCommands(resolvedSymbols); lenses[i].updateCommands(resolvedSymbols);
} }
}); });
......
...@@ -68,7 +68,7 @@ class CodeLensContentWidget implements editorBrowser.IContentWidget { ...@@ -68,7 +68,7 @@ class CodeLensContentWidget implements editorBrowser.IContentWidget {
line: number, line: number,
) { ) {
this._editor = editor; this._editor = editor;
this._id = (CodeLensContentWidget._idPool++).toString(); this._id = `codelens.widget-${(CodeLensContentWidget._idPool++)}`;
this.updatePosition(line); this.updatePosition(line);
...@@ -188,6 +188,7 @@ export class CodeLensWidget { ...@@ -188,6 +188,7 @@ export class CodeLensWidget {
private _contentWidget?: CodeLensContentWidget; private _contentWidget?: CodeLensContentWidget;
private _decorationIds: string[]; private _decorationIds: string[];
private _data: CodeLensItem[]; private _data: CodeLensItem[];
private _isDisposed: boolean = false;
constructor( constructor(
data: CodeLensItem[], data: CodeLensItem[],
...@@ -250,7 +251,13 @@ export class CodeLensWidget { ...@@ -250,7 +251,13 @@ export class CodeLensWidget {
} }
if (this._contentWidget) { if (this._contentWidget) {
this._editor.removeContentWidget(this._contentWidget); this._editor.removeContentWidget(this._contentWidget);
this._contentWidget = undefined;
} }
this._isDisposed = true;
}
isDisposed(): boolean {
return this._isDisposed;
} }
isValid(): boolean { isValid(): boolean {
...@@ -315,7 +322,7 @@ export class CodeLensWidget { ...@@ -315,7 +322,7 @@ export class CodeLensWidget {
} }
update(viewZoneChangeAccessor: editorBrowser.IViewZoneChangeAccessor): void { update(viewZoneChangeAccessor: editorBrowser.IViewZoneChangeAccessor): void {
if (this.isValid() && this._editor.hasModel()) { if (this.isValid()) {
const range = this._editor.getModel().getDecorationRange(this._decorationIds[0]); const range = this._editor.getModel().getDecorationRange(this._decorationIds[0]);
if (range) { if (range) {
this._viewZone.afterLineNumber = range.startLineNumber - 1; this._viewZone.afterLineNumber = range.startLineNumber - 1;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册