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

TerminalShellExecution#cwd should not be an URI or string #208638

Closed
jrieken opened this issue Mar 25, 2024 · 6 comments · Fixed by #209068
Closed

TerminalShellExecution#cwd should not be an URI or string #208638

jrieken opened this issue Mar 25, 2024 · 6 comments · Fixed by #209068
Assignees
Labels
api bug Issue identified by VS Code Team member as probable bug insiders-released Patch has been released in VS Code Insiders terminal-shell-integration Shell integration, command decorations, etc. verified Verification succeeded
Milestone

Comments

@jrieken
Copy link
Member

jrieken commented Mar 25, 2024

Testing #208462

The cwd: Uri | string | undefined; doesn't seem helpful because string basically means "VS Code couldn't figure this out, good luck to you". In the API we do the hard part and extensions should have easy times, meaning it should be URI | undefined

@jrieken
Copy link
Member Author

jrieken commented Mar 25, 2024

same for TerminalShellIntegration#cwd

@Tyriar
Copy link
Member

Tyriar commented Mar 25, 2024

It will actually never be a URI currently but it was added for future compatibility.

VS Code couldn't figure this out, good luck to you

This is a very valid scenario, consider SSHing some remote that VS Code knows nothing about, or some shell reports via a virtual file system that we're not aware of, etc.

@Tyriar Tyriar added the info-needed Issue requires more information from poster label Mar 25, 2024
@Tyriar Tyriar added this to the April 2024 milestone Mar 25, 2024
@jrieken
Copy link
Member Author

jrieken commented Mar 25, 2024

How should an extension use the cwd when delivered as string? All of our APIs are uri-based and strings are usually assumed as file-uris.

This is a very valid scenario, consider SSHing some remote that VS Code knows nothing about, or some shell reports via a virtual file system that we're not aware of, etc.

Make it undefined in such cases until we have a better fix. If we cannot get this right, don't offer such an API

@Tyriar
Copy link
Member

Tyriar commented Mar 25, 2024

We've touched on this in a past API sync a few months ago and URI | string | undefined was fine back then if I remember right.

It's worth mentioning that there are several shell/process-related cwds as strings currently, where these are the strings directly passed to spawn:

export interface ProcessExecutionOptions {
/**
* The current working directory of the executed program or shell.
* If omitted the tools current workspace root is used.
*/
cwd?: string;

/**
* The current working directory of the executed shell.
* If omitted the tools current workspace root is used.
*/
cwd?: string;

vscode/src/vscode-dts/vscode.d.ts

Lines 11720 to 11723 in 738438c

/**
* A path or Uri for the current working directory to be used for the terminal.
*/
cwd?: string | Uri;

Make it undefined in such cases until we have a better fix. If we cannot get this right, don't offer such an API

I don't think it's possible to get this as a URI, so we would be hiding information that may be useful - for example we find it useful and display the cwd in the terminal tab, exactly as it's reported by the shell. Shells can give us whatever they want for the cwd. If we went with URI | undefined it would be a breaking change to switch to URI | string | undefined, in addition to being inconsistent with TerminalOptions.cwd.

@jrieken
Copy link
Member Author

jrieken commented Mar 25, 2024

Aren't those samples all about extensions giving data to us, not us giving data to extensions?

@Tyriar
Copy link
Member

Tyriar commented Mar 25, 2024

Yep. Thanks for the feedback, I'll have a deeper think about it next month

@Tyriar Tyriar added bug Issue identified by VS Code Team member as probable bug api terminal-shell-integration Shell integration, command decorations, etc. and removed info-needed Issue requires more information from poster labels Mar 25, 2024
@VSCodeTriageBot VSCodeTriageBot added unreleased Patch has not yet been released in VS Code Insiders insiders-released Patch has been released in VS Code Insiders and removed unreleased Patch has not yet been released in VS Code Insiders labels Mar 28, 2024
@jrieken jrieken added the verified Verification succeeded label Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api bug Issue identified by VS Code Team member as probable bug insiders-released Patch has been released in VS Code Insiders terminal-shell-integration Shell integration, command decorations, etc. verified Verification succeeded
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants