Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 8, 2025

Description

Terminal path suggestions were incorrectly resolving against the local filesystem when connected via Remote SSH. Typing cd / in a Linux remote terminal would suggest Windows host directories (/Program Files/, /Windows/) instead of remote directories.

The issue occurred because path resolution used URI.file(), which always creates local file:// URIs, ignoring the remote scheme in the terminal's cwd URI (e.g., vscode-remote://ssh-remote+hostname/path).

Changes

Changed all path resolution to use cwd.with({ path }) instead of URI.file(), preserving the URI scheme and authority:

  • Absolute paths: /foo now resolves with remote scheme when cwd is remote
  • Tilde paths: ~/ now resolves to remote home directory
  • CDPATH entries: Now resolve against remote filesystem
  • Tilde completion detail: Simplified to avoid unnecessary path operations

Added test coverage for remote SSH URI schemes in both absolute and tilde path scenarios.

Example

Before:

// Always creates local URI regardless of remote context
lastWordFolderResource = URI.file('/foo');
// → file:///foo (wrong when remote)

After:

// Preserves scheme/authority from cwd
lastWordFolderResource = cwd.with({ path: '/foo' });
// → vscode-remote://ssh-remote+hostname/foo (correct)
Original prompt

This section details on the original issue you should resolve

<issue_title>terminal.integrated.suggest with Remote - SSH suggests host directories</issue_title>
<issue_description>Type: Bug

Connecting to a Linux remote from a Windows host with terminal.integrated.suggest enabled.

When typing cd / in the Linux terminal, it suggests directories from my Windows host instead of the Linux remote:

Image


VS Code version: Code - Insiders 1.101.0-insider (9bb394b, 2025-05-27T06:34:19.809Z)
OS version: Windows_NT x64 10.0.26100
Modes:
Remote OS version: Linux x64 5.15.167.4-microsoft-standard-WSL2
</issue_description>

Comments on the Issue (you are @copilot in this section)

@meganrogge Is this still happening for you?

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits December 8, 2025 18:05
…lde paths

- Modified terminalCompletionService.ts to use cwd.with({ path }) instead of URI.file()
- This preserves the remote scheme (e.g., vscode-remote://ssh-remote+hostname) when constructing URIs
- Fixed absolute path handling, tilde path handling, and CDPATH handling
- Added test cases for remote SSH scenarios

Co-authored-by: meganrogge <29464607+meganrogge@users.noreply.github.com>
Simplified the logic for showing ~ completion in relative paths. The previous code was using URI.joinPath with lastWordFolder.slice(1) which didn't make sense in this context since lastWordFolder is empty when showing the ~ completion.

Co-authored-by: meganrogge <29464607+meganrogge@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix terminal integrated suggest for Remote - SSH Fix terminal suggestions showing local paths in remote SSH terminals Dec 8, 2025
Copilot AI requested a review from meganrogge December 8, 2025 18:09
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.integrated.suggest with Remote - SSH suggests host directories

2 participants