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

Expose shell type to extensions #237624

Closed
wants to merge 39 commits into from
Closed

Conversation

anthonykim1
Copy link
Contributor

@anthonykim1 anthonykim1 commented Jan 10, 2025

Resolves: #230165

@Tyriar Tyriar self-assigned this Jan 14, 2025
@Tyriar Tyriar added this to the January 2025 milestone Jan 14, 2025
Comment on lines 274 to 277
case PosixShellType.Sh: extHostType = 1; break;
case PosixShellType.Bash: extHostType = 2; break;
case PosixShellType.Fish: extHostType = 3; break;
case PosixShellType.Csh: extHostType = 4; break;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at this now, you'd be better off just copying the enum from the API and duplicating it here. You could add a comment on top stating that it's important it keeps in sync

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean something like this?

Or having something like case vscode.TerminalShellType.Sh: extHostType = 1; break;?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like this:

                // IMPORTANT: This must stay in sync with the extension host API type.
		enum VscodeTerminalShellType {
			Sh = 1,
			Bash,
			Fish,
			Csh,
			Ksh,
			Zsh,
			CommandPrompt,
			GitBash,
			PowerShell,
			Python,
			Julia,
			NuShell
		}
		switch (shellType) {
			case PosixShellType.Sh: extHostType = VscodeTerminalShellType.Sh; break;
			case PosixShellType.Bash: extHostType = VscodeTerminalShellType.Bash; break;

Copy link
Contributor Author

@anthonykim1 anthonykim1 Jan 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this!
Now should be here

And is the reason why we choose not to directly import the VScodeTerminalShellType or TerminalShellType (as named in proposed api file) from terminal shell type proposed api file is because we are already using internal TerminalShellType from src/vs/platform/terminal/common/terminal.ts

export type TerminalShellType = PosixShellType | WindowsShellType | GeneralShellType;

right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're duplicating because we're not allowed to import anything but types from vscode. An enum isn't just a type but it also has an implementation (sh = 1, etc.).

@anthonykim1
Copy link
Contributor Author

TODO: Copy all content to branch on upstream since build+tests wont run in fork based PR branch, if I recall correctly.

anthonykim1 added a commit that referenced this pull request Jan 16, 2025
anthonykim1 added a commit that referenced this pull request Jan 17, 2025
* copy everything from #237624

* try to better word notes in proposed.d.ts

* why is test being so flaky

* try sending one more text

* strictEqual only on isInteractedWith always fails

* update the name as recommended

* embed to make sure we are selecting event we are interested in as recommended

* add node as part of TerminalShellType

* getting type ..extHostTypes.TerminalShellType.Bash is not comparable to type ..vscode.TerminalShellType.Bash

* just use one enum?

* figured out how to get from extHostTypes

* clean up
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

API to access the shell type for a given terminal
2 participants