-
Notifications
You must be signed in to change notification settings - Fork 30k
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
Expose shell type to extensions #237624
base: main
Are you sure you want to change the base?
Expose shell type to extensions #237624
Changes from 3 commits
1affd37
63a931c
26b6986
2020869
73a79dd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,6 +87,7 @@ export class MainThreadTerminalService implements MainThreadTerminalServiceShape | |
this._store.add(_terminalService.onAnyInstanceTitleChange(instance => instance && this._onTitleChanged(instance.instanceId, instance.title))); | ||
this._store.add(_terminalService.onAnyInstanceDataInput(instance => this._proxy.$acceptTerminalInteraction(instance.instanceId))); | ||
this._store.add(_terminalService.onAnyInstanceSelectionChange(instance => this._proxy.$acceptTerminalSelection(instance.instanceId, instance.selection))); | ||
this._store.add(_terminalService.onAnyInstanceShellTypeChange(instance => this._onShellTypeChanged(instance.instanceId, instance.shellType))); // Do I need this? I don't think so | ||
|
||
// Set initial ext host state | ||
for (const instance of this._terminalService.instances) { | ||
|
@@ -353,6 +354,13 @@ export class MainThreadTerminalService implements MainThreadTerminalServiceShape | |
this._proxy.$acceptTerminalTitleChange(terminalId, name); | ||
} | ||
|
||
private _onShellTypeChanged(terminalId: number, shellType: string): void { | ||
const terminalInstance = this._terminalService.getInstanceFromId(terminalId)?.shellType; | ||
if (terminalInstance) { | ||
this._proxy.$acceptTerminalShellType(terminalId, shellType); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You'll also want to set it when |
||
} | ||
|
||
private _onTerminalDisposed(terminalInstance: ITerminalInstance): void { | ||
this._proxy.$acceptTerminalClosed(terminalInstance.instanceId, terminalInstance.exitCode, terminalInstance.exitReason ?? TerminalExitReason.Unknown); | ||
} | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -18,7 +18,7 @@ import { serializeEnvironmentDescriptionMap, serializeEnvironmentVariableCollect | |||||||||||||
import { CancellationTokenSource } from '../../../base/common/cancellation.js'; | ||||||||||||||
import { generateUuid } from '../../../base/common/uuid.js'; | ||||||||||||||
import { IEnvironmentVariableCollectionDescription, IEnvironmentVariableMutator, ISerializableEnvironmentVariableCollection } from '../../../platform/terminal/common/environmentVariable.js'; | ||||||||||||||
import { ICreateContributedTerminalProfileOptions, IProcessReadyEvent, IShellLaunchConfigDto, ITerminalChildProcess, ITerminalLaunchError, ITerminalProfile, TerminalIcon, TerminalLocation, IProcessProperty, ProcessPropertyType, IProcessPropertyMap } from '../../../platform/terminal/common/terminal.js'; | ||||||||||||||
import { ICreateContributedTerminalProfileOptions, IProcessReadyEvent, IShellLaunchConfigDto, ITerminalChildProcess, ITerminalLaunchError, ITerminalProfile, TerminalIcon, TerminalLocation, IProcessProperty, ProcessPropertyType, IProcessPropertyMap, TerminalShellType, GeneralShellType } from '../../../platform/terminal/common/terminal.js'; | ||||||||||||||
import { TerminalDataBufferer } from '../../../platform/terminal/common/terminalDataBuffering.js'; | ||||||||||||||
import { ThemeColor } from '../../../base/common/themables.js'; | ||||||||||||||
import { Promises } from '../../../base/common/async.js'; | ||||||||||||||
|
@@ -419,6 +419,8 @@ export abstract class BaseExtHostTerminalService extends Disposable implements I | |||||||||||||
readonly onDidChangeTerminalState = this._onDidChangeTerminalState.event; | ||||||||||||||
protected readonly _onDidChangeShell = new Emitter<string>(); | ||||||||||||||
readonly onDidChangeShell = this._onDidChangeShell.event; | ||||||||||||||
// Should onDidChange/AcceptShellType go here? | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nope, the event would be on the |
||||||||||||||
|
||||||||||||||
|
||||||||||||||
protected readonly _onDidWriteTerminalData = new Emitter<vscode.TerminalDataWriteEvent>({ | ||||||||||||||
onWillAddFirstListener: () => this._proxy.$startSendingDataEvents(), | ||||||||||||||
|
@@ -764,6 +766,11 @@ export abstract class BaseExtHostTerminalService extends Disposable implements I | |||||||||||||
|
||||||||||||||
return completions; | ||||||||||||||
} | ||||||||||||||
// Take in shellType as a string and return VSCode Terminal Shell Type? | ||||||||||||||
public async $acceptTerminalShellType(id: number, shellType: string): Promise<TerminalShellType> { | ||||||||||||||
// TODO: Implement | ||||||||||||||
return GeneralShellType.Python; | ||||||||||||||
} | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Look at this for something similar to what you need to do: vscode/src/vs/workbench/api/common/extHostTerminalService.ts Lines 686 to 691 in e8184ed
Basically get the terminal for the ID, set it on it (interacted with is also on the |
||||||||||||||
|
||||||||||||||
public registerTerminalQuickFixProvider(id: string, extensionId: string, provider: vscode.TerminalQuickFixProvider): vscode.Disposable { | ||||||||||||||
if (this._quickFixProviders.has(id)) { | ||||||||||||||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -262,7 +262,7 @@ export interface ITerminalService extends ITerminalInstanceHost { | |||||||||||||||||||||||||
readonly onDidRequestStartExtensionTerminal: Event<IStartExtensionTerminalRequest>; | ||||||||||||||||||||||||||
readonly onDidRegisterProcessSupport: Event<void>; | ||||||||||||||||||||||||||
readonly onDidChangeConnectionState: Event<void>; | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
readonly onAnyInstanceShellTypeChanged: Event<ITerminalInstance>; // Here or on proposed api? - also there is onDidChangeShellType that already exists.. | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||||||||||||||||||||||
// Group events | ||||||||||||||||||||||||||
readonly onDidChangeActiveGroup: Event<ITerminalGroup | undefined>; | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
|
@@ -705,7 +705,7 @@ export interface ITerminalInstance extends IBaseTerminalInstance { | |||||||||||||||||||||||||
onDidExecuteText: Event<void>; | ||||||||||||||||||||||||||
onDidChangeTarget: Event<TerminalLocation | undefined>; | ||||||||||||||||||||||||||
onDidSendText: Event<string>; | ||||||||||||||||||||||||||
onDidChangeShellType: Event<TerminalShellType>; | ||||||||||||||||||||||||||
onDidChangeShellType: Event<TerminalShellType>; // how should this be used in correlation to my api which should expose shell type | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the raw event that your This is sent on the pty host:
This forwards it to vscode/src/vs/platform/terminal/node/ptyService.ts Lines 757 to 759 in e8184ed
vscode/src/vs/workbench/contrib/terminal/electron-sandbox/localTerminalBackend.ts Line 142 in e8184ed
vscode/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts Lines 1419 to 1421 in e8184ed
It's so complicated mainly due to the process jumps and multiple types of pty host (remote and local). |
||||||||||||||||||||||||||
onDidChangeVisibility: Event<boolean>; | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1910,6 +1910,8 @@ export class TerminalInstance extends Disposable implements ITerminalInstance { | |
this._shellType = shellType; | ||
this._terminalShellTypeContextKey.set(shellType?.toString()); | ||
this._onDidChangeShellType.fire(shellType); | ||
// Can I fire here to let my new API know? but how should I do that | ||
|
||
Comment on lines
+1913
to
+1914
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nope, you got the main listener done with the |
||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes this is the main listener that triggers the send to the exthost