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

define pathSeparator in ext host for terminal suggest #239540

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

meganrogge
Copy link
Contributor

fix #239411

@meganrogge meganrogge requested a review from Tyriar February 3, 2025 22:38
@meganrogge meganrogge self-assigned this Feb 3, 2025
@meganrogge meganrogge added this to the February 2025 milestone Feb 3, 2025
@meganrogge
Copy link
Contributor Author

failing tests

Comment on lines 137 to 141
/**
* Whether to normalize the path by replacing / with
* \\. This should be true when the OS is Windows.
*/
shouldNormalizePath?: boolean;
Copy link
Member

Choose a reason for hiding this comment

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

Should we just derive this from pathSeparator and always normalize in TerminalCompletionService when pathSeparator is \? The path separator could also be optional and default to \ when the ext host is Windows.

I'm also thinking of how we would apply this for the special cases like git bash and wsl (not on remote). For those we'd actually need some mapping function or call to correctly convert the paths so just setting pathSeparator to / won't be sufficient. Perhaps we should just not include this or pathSeparator this on the API at all for now and pass it through from exthost -> renderer, just not in the API. Then when think more about git bash/wsl support we can come up with a more robust solution, we may need something like this:

pathStyle: 'os' | 'wsl' | 'gitbash'`

@meganrogge meganrogge reopened this Feb 4, 2025
@meganrogge meganrogge changed the title add shouldNormalizePath to terminal suggest resource request config define pathSeparator in ext host for terminal suggest Feb 4, 2025
@meganrogge meganrogge requested a review from Tyriar February 4, 2025 19:05
@meganrogge meganrogge enabled auto-merge (squash) February 4, 2025 19:14
@@ -208,7 +206,8 @@ export class TerminalCompletionService extends Disposable implements ITerminalCo
}

async resolveResources(resourceRequestConfig: TerminalResourceRequestConfig, promptValue: string, cursorPosition: number, provider: string, capabilities: ITerminalCapabilityStore): Promise<ITerminalCompletion[] | undefined> {
if (resourceRequestConfig.shouldNormalizePrefix) {
const useBackslash = resourceRequestConfig.pathSeparator === '\\';
Copy link
Member

Choose a reason for hiding this comment

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

Little more obvious? useWindowsStylePath

@@ -65,7 +64,6 @@ export interface TerminalResourceRequestConfig {
foldersRequested?: boolean;
cwd?: URI;
pathSeparator: string;
Copy link
Member

Choose a reason for hiding this comment

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

I think this type should live in extHost.protocol.ts as that defines types used across exthost and main procs?

if (Array.isArray(completions)) {
return completions;
} else {
return new TerminalCompletionList(completions.items, { ...completions.resourceRequestConfig, pathSeparator: isWindows ? '\\' : '/' });
Copy link
Member

Choose a reason for hiding this comment

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

I think we want to convert this to a DTO in extHost.protocol.ts so we're not passing an object over IPC which could serialize incorrectly

@@ -779,7 +780,7 @@ export abstract class BaseExtHostTerminalService extends Disposable implements I
});
}

public async $provideTerminalCompletions(id: string, options: ITerminalCompletionContextDto): Promise<vscode.TerminalCompletionItem[] | vscode.TerminalCompletionList | undefined> {
public async $provideTerminalCompletions(id: string, options: ITerminalCompletionContextDto): Promise<vscode.TerminalCompletionItem[] | TerminalCompletionList | undefined> {
Copy link
Member

Choose a reason for hiding this comment

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

It was extHost.protocol.ts I was thinking of here, that defines types that go across IPC. We shouldn't be returning objects or API interfaces here.

See $provideTerminalQuickFixes as an example:

public async $provideTerminalQuickFixes(id: string, matchResult: TerminalCommandMatchResultDto): Promise<(ITerminalQuickFixTerminalCommandDto | ITerminalQuickFixOpenerDto | ICommandDto)[] | ITerminalQuickFixTerminalCommandDto | ITerminalQuickFixOpenerDto | ICommandDto | undefined> {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah that makes more sense - I had recalled you said extHostTypes, but was confused bc that is still in browser so would be wrong for remote.

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.

Terminal suggest: Don't rely on isWindows in resolveResources
3 participants