Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

re #147183. Support editor options in IDefaultEditor #147816

Merged
merged 4 commits into from
Apr 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/vs/platform/window/common/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { isLinux, isMacintosh, isNative, isWeb } from 'vs/base/common/platform';
import { URI, UriComponents } from 'vs/base/common/uri';
import { ISandboxConfiguration } from 'vs/base/parts/sandbox/common/sandboxTypes';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IEditorOptions } from 'vs/platform/editor/common/editor';
import { NativeParsedArgs } from 'vs/platform/environment/common/argv';
import { FileType } from 'vs/platform/files/common/files';
import { LogLevel } from 'vs/platform/log/common/log';
Expand Down Expand Up @@ -178,8 +179,15 @@ export interface IPathData {
// the file path to open within the instance
readonly fileUri?: UriComponents;

/**
* Optional editor options to apply in the file
*/
readonly options?: IEditorOptions;
rebornix marked this conversation as resolved.
Show resolved Hide resolved

/**
* An optional selection to apply in the file
*
* @deprecated Use options instead
*/
readonly selection?: {
readonly startLineNumber: number;
Expand All @@ -201,8 +209,12 @@ export interface IPathData {
// if it exists
readonly openOnlyIfExists?: boolean;

// Specifies an optional id to override the editor
// used to edit the resource, e.g. custom editor.
/**
* Specifies an optional id to override the editor
* used to edit the resource, e.g. custom editor.
*
* @deprecated Use options.override instead
*/
readonly editorOverrideId?: string;
}

Expand Down
3 changes: 2 additions & 1 deletion src/vs/workbench/browser/layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,8 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
endColumn: isNumber(file.selection.end.line) ? (isNumber(file.selection.end.column) ? file.selection.end.column : 1) : undefined,
} : undefined,
openOnlyIfExists: file.openOnlyIfExists,
editorOverrideId: file.openWith
editorOverrideId: file.openWith,
options: file.options
};
})
};
Expand Down
8 changes: 8 additions & 0 deletions src/vs/workbench/browser/web.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import type { TunnelProviderFeatures } from 'vs/platform/tunnel/common/tunnel';
import type { IProgress, IProgressCompositeOptions, IProgressDialogOptions, IProgressNotificationOptions, IProgressOptions, IProgressStep, IProgressWindowOptions } from 'vs/platform/progress/common/progress';
import { IObservableValue } from 'vs/base/common/observableValue';
import { TelemetryLevel } from 'vs/platform/telemetry/common/telemetry';
import { IEditorOptions } from 'vs/platform/editor/common/editor';

/**
* The `IWorkbench` interface is the API facade for web embedders
Expand Down Expand Up @@ -580,9 +581,16 @@ export interface IRange {

export interface IDefaultEditor {
readonly uri: UriComponents;
/**
* @deprecated Use options instead
*/
readonly selection?: IRange;
readonly openOnlyIfExists?: boolean;
/**
* @deprecated Use options.override instead
*/
readonly openWith?: string;
readonly options?: IEditorOptions;
}

export interface IDefaultLayout {
Expand Down
9 changes: 6 additions & 3 deletions src/vs/workbench/common/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { assertIsDefined } from 'vs/base/common/types';
import { URI } from 'vs/base/common/uri';
import { Disposable, IDisposable, toDisposable } from 'vs/base/common/lifecycle';
import { ICodeEditorViewState, IDiffEditor, IDiffEditorViewState, IEditorViewState } from 'vs/editor/common/editorCommon';
import { IEditorOptions, ITextEditorOptions, IResourceEditorInput, ITextResourceEditorInput, IBaseTextResourceEditorInput, IBaseUntypedEditorInput } from 'vs/platform/editor/common/editor';
import { IEditorOptions, IResourceEditorInput, ITextResourceEditorInput, IBaseTextResourceEditorInput, IBaseUntypedEditorInput } from 'vs/platform/editor/common/editor';
import type { EditorInput } from 'vs/workbench/common/editor/editorInput';
import { IInstantiationService, IConstructorSignature, ServicesAccessor, BrandedService } from 'vs/platform/instantiation/common/instantiation';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
Expand Down Expand Up @@ -1340,8 +1340,11 @@ export async function pathsToEditors(paths: IPathData[] | undefined, fileService
return;
}

const options: ITextEditorOptions = {
selection: exists ? path.selection : undefined,
const options: IEditorOptions = {
...path.options,
...{
selection: exists ? path.selection : undefined
},
pinned: true,
override: path.editorOverrideId
};
Expand Down