Move onDidChangeActiveTextEditor event registration behind feature flag (#18283)

This commit is contained in:
Hai Cao 2024-10-18 16:45:05 -07:00 коммит произвёл GitHub
Родитель e1ebcb6742
Коммит 56694bdb0e
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
2 изменённых файлов: 29 добавлений и 14 удалений

Просмотреть файл

@ -531,6 +531,7 @@ export default class MainController implements vscode.Disposable {
this._context,
this.executionPlanService,
this.untitledSqlDocumentService,
this._vscodeWrapper,
);
// Init content provider for results pane

Просмотреть файл

@ -5,6 +5,7 @@
import * as vscode from "vscode";
import * as qr from "../sharedInterfaces/queryResult";
import * as Constants from "../constants/constants";
import { ReactWebviewViewController } from "../controllers/reactWebviewViewController";
import { SqlOutputContentProvider } from "../models/sqlOutputContentProvider";
import { sendActionEvent } from "../telemetry/telemetry";
@ -19,6 +20,7 @@ import { ApiStatus } from "../sharedInterfaces/webview";
import UntitledSqlDocumentService from "../controllers/untitledSqlDocumentService";
import { ExecutionPlanGraphInfo } from "../reactviews/pages/ExecutionPlan/executionPlanInterfaces";
import { ExecutionPlanService } from "../services/executionPlanService";
import VscodeWrapper from "../controllers/vscodeWrapper";
export class QueryResultWebviewController extends ReactWebviewViewController<
qr.QueryResultWebviewState,
@ -33,6 +35,7 @@ export class QueryResultWebviewController extends ReactWebviewViewController<
context: vscode.ExtensionContext,
private executionPlanService: ExecutionPlanService,
private untitledSqlDocumentService: UntitledSqlDocumentService,
private _vscodeWrapper: VscodeWrapper,
) {
super(context, "queryResult", {
resultSetSummaries: {},
@ -44,26 +47,37 @@ export class QueryResultWebviewController extends ReactWebviewViewController<
});
void this.initialize();
vscode.window.onDidChangeActiveTextEditor((editor) => {
const uri = editor?.document?.uri?.toString(true);
if (uri && this._queryResultStateMap.has(uri)) {
this.state = this.getQueryResultState(uri);
} else {
this.state = {
resultSetSummaries: {},
messages: [],
tabStates: undefined,
isExecutionPlan: false,
executionPlanState: {},
};
}
});
if (!_vscodeWrapper) {
this._vscodeWrapper = new VscodeWrapper();
}
if (this.isRichExperiencesEnabled) {
vscode.window.onDidChangeActiveTextEditor((editor) => {
const uri = editor?.document?.uri?.toString(true);
if (uri && this._queryResultStateMap.has(uri)) {
this.state = this.getQueryResultState(uri);
} else {
this.state = {
resultSetSummaries: {},
messages: [],
tabStates: undefined,
isExecutionPlan: false,
executionPlanState: {},
};
}
});
}
}
private async initialize() {
this.registerRpcHandlers();
}
private get isRichExperiencesEnabled(): boolean {
return this._vscodeWrapper
.getConfiguration()
.get(Constants.configEnableRichExperiences);
}
private registerRpcHandlers() {
this.registerRequestHandler("getRows", async (message) => {
return await this._sqlOutputContentProvider.rowRequestHandler(