mirror of
https://github.com/Microsoft/vscode
synced 2024-08-28 05:19:39 +00:00
This commit is contained in:
parent
84ef964f73
commit
b5d3ec5b49
|
@ -199,6 +199,13 @@ export class DisposableStore implements IDisposable {
|
|||
this.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns `true` if this object has been disposed
|
||||
*/
|
||||
public get isDisposed(): boolean {
|
||||
return this._isDisposed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispose of all registered disposables but do not mark this object as disposed.
|
||||
*/
|
||||
|
|
|
@ -28,6 +28,10 @@ export class CodeLensModel {
|
|||
this._disposables.dispose();
|
||||
}
|
||||
|
||||
get isDisposed(): boolean {
|
||||
return this._disposables.isDisposed;
|
||||
}
|
||||
|
||||
add(list: CodeLensList, provider: CodeLensProvider): void {
|
||||
this._disposables.add(list);
|
||||
for (const symbol of list.lenses) {
|
||||
|
|
|
@ -439,8 +439,8 @@ export class CodeLensContribution implements IEditorContribution {
|
|||
});
|
||||
}
|
||||
|
||||
getLenses(): readonly CodeLensWidget[] {
|
||||
return this._lenses;
|
||||
getModel(): CodeLensModel | undefined {
|
||||
return this._currentCodeLensModel;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -472,19 +472,20 @@ registerEditorAction(class ShowLensesInCurrentLine extends EditorAction {
|
|||
if (!codelensController) {
|
||||
return;
|
||||
}
|
||||
const items: { label: string, command: Command }[] = [];
|
||||
|
||||
for (let lens of codelensController.getLenses()) {
|
||||
if (lens.getLineNumber() === lineNumber) {
|
||||
for (let item of lens.getItems()) {
|
||||
const { command } = item.symbol;
|
||||
if (command) {
|
||||
items.push({
|
||||
label: command.title,
|
||||
command: command
|
||||
});
|
||||
}
|
||||
}
|
||||
const model = codelensController.getModel();
|
||||
if (!model) {
|
||||
// nothing
|
||||
return;
|
||||
}
|
||||
|
||||
const items: { label: string, command: Command }[] = [];
|
||||
for (const lens of model.lenses) {
|
||||
if (lens.symbol.command && lens.symbol.range.startLineNumber === lineNumber) {
|
||||
items.push({
|
||||
label: lens.symbol.command.title,
|
||||
command: lens.symbol.command
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -499,6 +500,11 @@ registerEditorAction(class ShowLensesInCurrentLine extends EditorAction {
|
|||
return;
|
||||
}
|
||||
|
||||
if (model.isDisposed) {
|
||||
// retry whenever the model has been disposed
|
||||
return await commandService.executeCommand(this.id);
|
||||
}
|
||||
|
||||
try {
|
||||
await commandService.executeCommand(item.command.id, ...(item.command.arguments || []));
|
||||
} catch (err) {
|
||||
|
|
Loading…
Reference in a new issue