Path: blob/main/extensions/copilot/src/extension/notebook/vscode-node/followActions.ts
13399 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import * as vscode from 'vscode';6import { ConfigKey, IConfigurationService } from '../../../platform/configuration/common/configurationService';7import { Event } from '../../../util/vs/base/common/event';8import { Disposable } from '../../../util/vs/base/common/lifecycle';9import { INotebookService } from '../../../platform/notebook/common/notebookService';1011const NOTEBOOK_FOLLOW_IN_SESSION_KEY = 'github.copilot.notebookFollowInSessionEnabled';1213export class NotebookFollowCommands extends Disposable {1415private followSettingEnabled: boolean;1617constructor(18@IConfigurationService private readonly _configurationService: IConfigurationService,19@INotebookService private readonly _notebookService: INotebookService20) {21super();2223// get setting and set initial follower context state24this.followSettingEnabled = this._configurationService.getConfig(ConfigKey.NotebookFollowCellExecution);25this.updateFollowContext(this.followSettingEnabled);2627// config listener to disable if the setting changes28this._register(Event.runAndSubscribe(this._configurationService.onDidChangeConfiguration, e => {29if (!e || e.affectsConfiguration(ConfigKey.NotebookFollowCellExecution.fullyQualifiedId)) {30this.followSettingEnabled = this._configurationService.getConfig(ConfigKey.NotebookFollowCellExecution);31this.updateFollowContext(this.followSettingEnabled);32}33}));3435// commands to change context state36this._register(vscode.commands.registerCommand('github.copilot.chat.notebook.enableFollowCellExecution', () => {37this.updateFollowContext(true);38}));3940this._register(vscode.commands.registerCommand('github.copilot.chat.notebook.disableFollowCellExecution', () => {41this.updateFollowContext(false);42}));43}4445private updateFollowContext(value: boolean): void {46vscode.commands.executeCommand('setContext', NOTEBOOK_FOLLOW_IN_SESSION_KEY, value);47this._notebookService.setFollowState(value);4849}50}515253