diff --git a/client/src/session/SessionRepository.ts b/client/src/session/SessionRepository.ts index 22f6cb29..8a02c6de 100644 --- a/client/src/session/SessionRepository.ts +++ b/client/src/session/SessionRepository.ts @@ -3,7 +3,8 @@ * Licensed under the MIT License. See License.txt in the project root for license information. * ------------------------------------------------------------------------------------------ */ -import { QuickDiffProvider, Uri, CancellationToken, ProviderResult, WorkspaceFolder, workspace } from "vscode"; +import { QuickDiffProvider, window, Uri, CancellationToken, ProviderResult, WorkspaceFolder, workspace } from "vscode"; +import * as vscode from 'vscode'; import * as path from 'path'; import { compareMaps } from "../utils"; import { SessionConfiguration, strMapToObj, SessionMode } from "./SessionConfiguration"; @@ -165,7 +166,6 @@ export async function duplicateSession(session: SessionContent): Promise } const SAVE_TABS_PLUGIN_NAME = "save-tabs"; -const SOLVER_PLUGIN_NAME = "solver"; /** * Fetches session from the planning.domains server. @@ -207,11 +207,26 @@ async function getRawSession(sessionConfiguration: SessionConfiguration): Promis if(pluginsMatch = SESSION_PLUGINS_PATTERN.exec(sessionContent)) { let rawPlugins = JSON.parse(pluginsMatch[1]); - [SAVE_TABS_PLUGIN_NAME, SOLVER_PLUGIN_NAME].forEach(pluginName => { - if (rawPlugins.hasOwnProperty(pluginName)) { - plugins.set(pluginName, toRawSessionPlugin(pluginName, rawPlugins[pluginName])); + // Save all of the plugins found (even if we don't use them all) + for (let pluginName in rawPlugins) { + plugins.set(pluginName, toRawSessionPlugin(pluginName, rawPlugins[pluginName])); + + // Process vscode injection components + if (rawPlugins[pluginName]['settings'].hasOwnProperty('vscode-injection')) { + // Confirm with user (since we're using eval) + let answer = await window.showQuickPick(["Yes", "No"], + { placeHolder: `Allow code injection from ${pluginName} extension?` }); + if (answer === "Yes") { + try { + var vscode_settings = {vscode: vscode}; + var cb = eval(rawPlugins[pluginName]['settings']['vscode-injection']); + cb(rawPlugins[pluginName]['settings'], vscode_settings); + } catch (ex) { + throw new Error("Failed to run plugin's vscode injection code: " + ex); + } + } } - }); + } } else { console.log("Malformed saved session plugins. Could not extract session plugins. Session content:" + sessionContent); diff --git a/client/src/session/SessionSourceControl.ts b/client/src/session/SessionSourceControl.ts index aacec3f0..b7fa0b07 100644 --- a/client/src/session/SessionSourceControl.ts +++ b/client/src/session/SessionSourceControl.ts @@ -10,7 +10,6 @@ import { toFuzzyRelativeTime } from '../utils'; import * as afs from '../../../common/src/asyncfs'; import * as fs from 'fs'; import { SessionConfiguration, saveConfiguration, SessionMode, toSessionConfiguration, CONFIGURATION_FILE } from './SessionConfiguration'; -import { PDDL_PLANNER, EXECUTABLE_OR_SERVICE } from '../configuration'; /** * Command for cloning a session to the local storage. @@ -226,8 +225,6 @@ export class SessionSourceControl implements vscode.Disposable { if (overwrite) { this.resetFilesToCheckedOutVersion(); } // overwrite local file content this._onRepositoryChange.fire(this.session); await this.updateChangedGroup(); - await this.saveWorkspaceSettings(); - await this.saveCurrentConfiguration(); } @@ -252,20 +249,6 @@ export class SessionSourceControl implements vscode.Disposable { return await saveConfiguration(this.workspaceFolder.uri, this.session); } - private static readonly SOLVER_PLUGIN = "solver"; - - /** Saves setting of eligible session plugins to workspace configuration. */ - async saveWorkspaceSettings(): Promise { - if (this.session.plugins.has(SessionSourceControl.SOLVER_PLUGIN)) { - let solver = this.session.plugins.get(SessionSourceControl.SOLVER_PLUGIN); - if (solver.url !== "/plugins/solver.js") { return; } - - let solverUrl = solver.settings["url"]; - - await vscode.workspace.getConfiguration(PDDL_PLANNER, this.workspaceFolder.uri).update(EXECUTABLE_OR_SERVICE, solverUrl + "/solve", vscode.ConfigurationTarget.WorkspaceFolder); - } - } - /** * Refresh is used when the information on the server may have changed. * For example another user updates the session files online.