未验证 提交 c8ccd07d 编写于 作者: D Daniel Imms

Add initialText proposed API

Part of #120368
上级 062ed070
...@@ -812,6 +812,19 @@ declare module 'vscode' { ...@@ -812,6 +812,19 @@ declare module 'vscode' {
//#endregion //#endregion
//#region Terminal initial text https://github.com/microsoft/vscode/issues/120368
export interface TerminalOptions {
/**
* Initial text to write to the terminal, note that this is not sent to the process but
* rather written directly to the terminal. This supports escape sequences such a setting
* text style.
*/
readonly initialText?: string;
}
//#endregion
// eslint-disable-next-line vscode-dts-region-comments // eslint-disable-next-line vscode-dts-region-comments
//#region @jrieken -> exclusive document filters //#region @jrieken -> exclusive document filters
......
...@@ -123,6 +123,7 @@ export class MainThreadTerminalService implements MainThreadTerminalServiceShape ...@@ -123,6 +123,7 @@ export class MainThreadTerminalService implements MainThreadTerminalServiceShape
executable: launchConfig.shellPath, executable: launchConfig.shellPath,
args: launchConfig.shellArgs, args: launchConfig.shellArgs,
cwd: typeof launchConfig.cwd === 'string' ? launchConfig.cwd : URI.revive(launchConfig.cwd), cwd: typeof launchConfig.cwd === 'string' ? launchConfig.cwd : URI.revive(launchConfig.cwd),
initialText: launchConfig.initialText,
waitOnExit: launchConfig.waitOnExit, waitOnExit: launchConfig.waitOnExit,
ignoreConfigurationCwd: true, ignoreConfigurationCwd: true,
env: launchConfig.env, env: launchConfig.env,
......
...@@ -633,6 +633,9 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I ...@@ -633,6 +633,9 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
if ('pty' in nameOrOptions) { if ('pty' in nameOrOptions) {
return extHostTerminalService.createExtensionTerminal(nameOrOptions); return extHostTerminalService.createExtensionTerminal(nameOrOptions);
} }
if (nameOrOptions.initialText) {
checkProposedApiEnabled(extension);
}
return extHostTerminalService.createTerminalFromOptions(nameOrOptions); return extHostTerminalService.createTerminalFromOptions(nameOrOptions);
} }
return extHostTerminalService.createTerminal(nameOrOptions, shellPath, shellArgs); return extHostTerminalService.createTerminal(nameOrOptions, shellPath, shellArgs);
......
...@@ -455,6 +455,7 @@ export interface TerminalLaunchConfig { ...@@ -455,6 +455,7 @@ export interface TerminalLaunchConfig {
shellArgs?: string[] | string; shellArgs?: string[] | string;
cwd?: string | UriComponents; cwd?: string | UriComponents;
env?: ITerminalEnvironment; env?: ITerminalEnvironment;
initialText?: string;
waitOnExit?: boolean; waitOnExit?: boolean;
strictEnv?: boolean; strictEnv?: boolean;
hideFromUser?: boolean; hideFromUser?: boolean;
......
...@@ -118,6 +118,7 @@ export class ExtHostTerminal { ...@@ -118,6 +118,7 @@ export class ExtHostTerminal {
shellArgs?: string[] | string, shellArgs?: string[] | string,
cwd?: string | URI, cwd?: string | URI,
env?: ITerminalEnvironment, env?: ITerminalEnvironment,
initialText?: string,
waitOnExit?: boolean, waitOnExit?: boolean,
strictEnv?: boolean, strictEnv?: boolean,
hideFromUser?: boolean, hideFromUser?: boolean,
...@@ -127,7 +128,7 @@ export class ExtHostTerminal { ...@@ -127,7 +128,7 @@ export class ExtHostTerminal {
if (typeof this._id !== 'string') { if (typeof this._id !== 'string') {
throw new Error('Terminal has already been created'); throw new Error('Terminal has already been created');
} }
await this._proxy.$createTerminal(this._id, { name: this._name, shellPath, shellArgs, cwd, env, waitOnExit, strictEnv, hideFromUser, isFeatureTerminal, isExtensionOwnedTerminal }); await this._proxy.$createTerminal(this._id, { name: this._name, shellPath, shellArgs, cwd, env, initialText, waitOnExit, strictEnv, hideFromUser, isFeatureTerminal, isExtensionOwnedTerminal });
} }
public async createExtensionTerminal(): Promise<number> { public async createExtensionTerminal(): Promise<number> {
......
...@@ -65,6 +65,7 @@ export class ExtHostTerminalService extends BaseExtHostTerminalService { ...@@ -65,6 +65,7 @@ export class ExtHostTerminalService extends BaseExtHostTerminalService {
withNullAsUndefined(options.shellArgs), withNullAsUndefined(options.shellArgs),
withNullAsUndefined(options.cwd), withNullAsUndefined(options.cwd),
withNullAsUndefined(options.env), withNullAsUndefined(options.env),
withNullAsUndefined(options.initialText),
/*options.waitOnExit*/ undefined, /*options.waitOnExit*/ undefined,
withNullAsUndefined(options.strictEnv), withNullAsUndefined(options.strictEnv),
withNullAsUndefined(options.hideFromUser), withNullAsUndefined(options.hideFromUser),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册