Skip to content

Commit

Permalink
re #147183. Support editor options in IDefaultEditor
Browse files Browse the repository at this point in the history
  • Loading branch information
rebornix committed Apr 21, 2022
1 parent ad5ef7e commit ab4a542
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
6 changes: 6 additions & 0 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,6 +179,11 @@ 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;

/**
* An optional selection to apply in the file
*/
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
5 changes: 3 additions & 2 deletions src/vs/workbench/common/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1340,11 +1340,12 @@ export async function pathsToEditors(paths: IPathData[] | undefined, fileService
return;
}

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

let input: IResourceEditorInput | IUntitledTextResourceEditorInput;
if (!exists) {
Expand Down

0 comments on commit ab4a542

Please sign in to comment.