提交 a4347bef 编写于 作者: M Matt Bierner 提交者: GitHub

References code lens fire event when config is changed. Fixes #19195 (#19343)

上级 6c62ac73
......@@ -5,7 +5,7 @@
'use strict';
import { CodeLensProvider, CodeLens, CancellationToken, TextDocument, Range, Uri, Location, Position, workspace, WorkspaceConfiguration } from 'vscode';
import { CodeLensProvider, CodeLens, CancellationToken, TextDocument, Range, Uri, Location, Position, workspace, WorkspaceConfiguration, EventEmitter, Event } from 'vscode';
import * as Proto from '../protocol';
import * as PConst from '../protocol.const';
......@@ -27,16 +27,23 @@ class ReferencesCodeLens extends CodeLens {
}
export default class TypeScriptReferencesCodeLensProvider implements CodeLensProvider {
private client: ITypescriptServiceClient;
private enabled = false;
constructor(client: ITypescriptServiceClient) {
this.client = client;
private onDidChangeCodeLensesEmitter = new EventEmitter<CodeLensProvider>();
public get onDidChangeCodeLenses(): Event<CodeLensProvider> {
return this.onDidChangeCodeLensesEmitter.event;
}
constructor(private client: ITypescriptServiceClient) { }
public updateConfiguration(config: WorkspaceConfiguration): void {
let typeScriptConfig = workspace.getConfiguration('typescript');
const wasEnabled = this.enabled;
this.enabled = typeScriptConfig.get('referencesCodeLens.enabled', false);
if (wasEnabled !== this.enabled) {
this.onDidChangeCodeLensesEmitter.fire(this);
}
}
provideCodeLenses(document: TextDocument, token: CancellationToken): Promise<CodeLens[]> {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册