mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-08 17:19:48 +01:00
Merge branch 'main' into merogge/onExit
This commit is contained in:
@@ -478,7 +478,6 @@ suite('Notebook API tests', function () {
|
||||
const secondCell = vscode.window.activeNotebookEditor!.document.cellAt(1);
|
||||
assert.strictEqual(secondCell!.outputs.length, 1);
|
||||
assert.deepStrictEqual(secondCell!.outputs[0].metadata, { testOutputMetadata: true, ['text/plain']: { testOutputItemMetadata: true } });
|
||||
assert.strictEqual((<any>secondCell!.outputs[0]).outputs.length, 1); //todo@jrieken will FAIL once the backwards compatibility is gone
|
||||
assert.strictEqual(secondCell!.outputs[0].items.length, 1);
|
||||
assert.strictEqual(secondCell!.outputs[0].items[0].mime, 'text/plain');
|
||||
assert.strictEqual(new TextDecoder().decode(secondCell!.outputs[0].items[0].data), 'Hello World');
|
||||
|
||||
@@ -3,11 +3,17 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { ServicesAccessor } from 'vs/editor/browser/editorExtensions';
|
||||
import { localize } from 'vs/nls';
|
||||
import { Action2, registerAction2 } from 'vs/platform/actions/common/actions';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { optional } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { CellToolbarLocation, CompactView, ConsolidatedRunButton, FocusIndicator, GlobalToolbar, InsertToolbarPosition, ShowCellStatusBarAfterExecuteKey, ShowCellStatusBarKey, UndoRedoPerCell } from 'vs/workbench/contrib/notebook/common/notebookCommon';
|
||||
import { ITASExperimentService } from 'vs/workbench/services/experiment/common/experimentService';
|
||||
import { Extensions as WorkbenchExtensions, IWorkbenchContributionsRegistry } from 'vs/workbench/common/contributions';
|
||||
import { LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle';
|
||||
|
||||
export enum NotebookProfileType {
|
||||
default = 'default',
|
||||
@@ -24,7 +30,8 @@ const profiles = {
|
||||
[CompactView]: true,
|
||||
[ShowCellStatusBarKey]: true,
|
||||
[ShowCellStatusBarAfterExecuteKey]: false,
|
||||
[ConsolidatedRunButton]: true
|
||||
[ConsolidatedRunButton]: true,
|
||||
[UndoRedoPerCell]: false
|
||||
},
|
||||
[NotebookProfileType.jupyter]: {
|
||||
[FocusIndicator]: 'gutter',
|
||||
@@ -43,12 +50,12 @@ const profiles = {
|
||||
[CellToolbarLocation]: { default: 'right' },
|
||||
[CompactView]: false,
|
||||
[ShowCellStatusBarKey]: false,
|
||||
[ConsolidatedRunButton]: true
|
||||
[ConsolidatedRunButton]: true,
|
||||
[UndoRedoPerCell]: false
|
||||
}
|
||||
};
|
||||
|
||||
async function applyProfile(accessor: ServicesAccessor, profile: Record<string, any>): Promise<void> {
|
||||
const configService = accessor.get(IConfigurationService);
|
||||
async function applyProfile(configService: IConfigurationService, profile: Record<string, any>): Promise<void> {
|
||||
const promises = [];
|
||||
for (let settingKey in profile) {
|
||||
promises.push(configService.updateValue(settingKey, profile[settingKey]));
|
||||
@@ -74,7 +81,8 @@ registerAction2(class extends Action2 {
|
||||
return;
|
||||
}
|
||||
|
||||
return applyProfile(accessor, profiles[args.profile]);
|
||||
const configService = accessor.get(IConfigurationService);
|
||||
return applyProfile(configService, profiles[args.profile]);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -84,3 +92,42 @@ function isSetProfileArgs(args: unknown): args is ISetProfileArgs {
|
||||
setProfileArgs.profile === NotebookProfileType.default ||
|
||||
setProfileArgs.profile === NotebookProfileType.jupyter;
|
||||
}
|
||||
|
||||
export class NotebookProfileContribution extends Disposable {
|
||||
constructor(@IConfigurationService configService: IConfigurationService, @optional(ITASExperimentService) private readonly experimentService: ITASExperimentService) {
|
||||
super();
|
||||
|
||||
if (this.experimentService) {
|
||||
this.experimentService.getTreatment<NotebookProfileType.default | NotebookProfileType.jupyter | NotebookProfileType.colab>('notebookprofile').then(treatment => {
|
||||
if (treatment === undefined) {
|
||||
return;
|
||||
} else {
|
||||
// check if settings are already modified
|
||||
const focusIndicator = configService.getValue(FocusIndicator);
|
||||
const insertToolbarPosition = configService.getValue(InsertToolbarPosition);
|
||||
const globalToolbar = configService.getValue(GlobalToolbar);
|
||||
// const cellToolbarLocation = configService.getValue(CellToolbarLocation);
|
||||
const compactView = configService.getValue(CompactView);
|
||||
const showCellStatusBarKey = configService.getValue(ShowCellStatusBarKey);
|
||||
const showCellStatusBarAfterExecuteKey = configService.getValue(ShowCellStatusBarAfterExecuteKey);
|
||||
const consolidatedRunButton = configService.getValue(ConsolidatedRunButton);
|
||||
if (focusIndicator === 'border'
|
||||
&& insertToolbarPosition === 'both'
|
||||
&& globalToolbar === false
|
||||
// && cellToolbarLocation === undefined
|
||||
&& compactView === true
|
||||
&& showCellStatusBarKey === true
|
||||
&& showCellStatusBarAfterExecuteKey === false
|
||||
&& consolidatedRunButton === true
|
||||
) {
|
||||
applyProfile(configService, profiles[treatment] ?? profiles[NotebookProfileType.default]);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const workbenchContributionsRegistry = Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench);
|
||||
workbenchContributionsRegistry.registerWorkbenchContribution(NotebookProfileContribution, LifecyclePhase.Ready);
|
||||
|
||||
|
||||
@@ -8,6 +8,8 @@ import { CopyAction, CutAction, PasteAction } from 'vs/editor/contrib/clipboard/
|
||||
import * as nls from 'vs/nls';
|
||||
import { MenuId, MenuRegistry } from 'vs/platform/actions/common/actions';
|
||||
import { IWebviewService, Webview } from 'vs/workbench/contrib/webview/browser/webview';
|
||||
import { WebviewInput } from 'vs/workbench/contrib/webviewPanel/browser/webviewEditorInput';
|
||||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
|
||||
|
||||
const PRIORITY = 100;
|
||||
@@ -20,6 +22,13 @@ function overrideCommandForWebview(command: MultiCommand | undefined, f: (webvie
|
||||
f(webview);
|
||||
return true;
|
||||
}
|
||||
|
||||
const editorService = accessor.get(IEditorService);
|
||||
if (editorService.activeEditor instanceof WebviewInput) {
|
||||
f(editorService.activeEditor.webview);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ export class WorkspaceTrustRequestHandler extends Disposable implements IWorkben
|
||||
this.createStatusbarEntry();
|
||||
|
||||
// Set empty workspace trust state
|
||||
this.setEmptyWorkspaceTrustState();
|
||||
await this.setEmptyWorkspaceTrustState();
|
||||
|
||||
// Show modal dialog
|
||||
if (this.hostService.hasFocus) {
|
||||
|
||||
Reference in New Issue
Block a user