Skip to content

Fix call hierarchy file node paths - #64108

Draft
Ryan Cavanaugh (RyanCavanaugh) with Copilot wants to merge 5 commits into
mainfrom
copilot/fix-call-hierarchy-file-path
Draft

Ryan Cavanaugh (RyanCavanaugh) with Copilot wants to merge 5 commits into
mainfrom
copilot/fix-call-hierarchy-file-path

Conversation

Copilot AI commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

TypeScript 7 call hierarchy file nodes displayed absolute paths, making large hierarchies difficult to scan.

  • Display: Use the file basename as the node name.
  • Context: Show the project-relative containing directory as detail.
  • Navigation: Preserve the absolute file URI.
  • Coverage: Add a subdirectory regression case and update affected call hierarchy baselines.
Before: /workspace/src/callers.ts
After:  callers.ts  src

@typescript-automation typescript-automation Bot added the For Milestone Bug PRs that fix a bug with a specific milestone label Aug 31, 2026
@typescript-automation typescript-automation Bot added For Uncommitted Bug PR for untriaged, rejected, closed or missing bug and removed For Milestone Bug PRs that fix a bug with a specific milestone labels Aug 31, 2026
Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix call hierarchy to show relative file paths instead of absolute Fix call hierarchy file node paths Aug 31, 2026
@jakebailey

Copy link
Copy Markdown
Member

I'm not sure this is 100% right; it turns out that the old VS Code extension did vscode.workspace.asRelativePath(path.dirname(item.file)) which actually made the path relative to the workspace root.

I think we'd have to somehow plumb that info down from the init message.

@brian-xu-vlt

Copy link
Copy Markdown

Hi! As OP on the issue #64097, I was wondering if there is any progress on this issue? Can I help in any way?

@jakebailey

Copy link
Copy Markdown
Member

Copilot merge main and do better per the above

…archy-file-path

# Conflicts:
#	tsc/internal/ls/callhierarchy.go

Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>

Copilot AI commented Oct 31, 2026

Copy link
Copy Markdown
Contributor Author

Copilot merge main and do better per the above

Merged main in ce08218. In 1de9546, call hierarchy details use initialized workspace folders with typed paths, including named multi-root folders and VS Code’s workspace-root parent lookup. Navigation URIs remain unchanged. Build, tests, lint, and format passed; CodeQL was blocked by a Git diff timeout.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Workspace-folder selection relies on UTF-8 byte length rather than case-aware ancestry, which can select an outer folder on case-insensitive hosts and produce incorrect call-hierarchy details.

1 open issue
What changed in this PR

This PR addresses #64097 by making call hierarchy file nodes easier to scan in the native TypeScript language server while preserving navigation targets.

Changes:

  • Display file basenames with workspace-relative directory details where applicable.
  • Pass workspace folder paths and names from server initialization to the language service.
  • Add workspace regression cases and update call hierarchy baselines.
File Description
tsc/​testdata/​baselines/​reference/​fourslash/​callHierarchy/​callHierarchyInterfaceMethod.callHierarchy.txt Updates incoming file labels and directory details.
tsc/​testdata/​baselines/​reference/​fourslash/​callHierarchy/​callHierarchyFileWorkspaceRootUri.callHierarchy.txt Records root-URI-relative details.
tsc/​testdata/​baselines/​reference/​fourslash/​callHierarchy/​callHierarchyFileWorkspaceFolders.callHierarchy.txt Records nested workspace selection and naming.
tsc/​testdata/​baselines/​reference/​fourslash/​callHierarchy/​callHierarchyFileWorkspaceFolderRoot.callHierarchy.txt Records details for files at a workspace root.
tsc/​testdata/​baselines/​reference/​fourslash/​callHierarchy/​callHierarchyFileOutsideWorkspace.callHierarchy.txt Records absolute-directory fallback outside workspaces.
tsc/​testdata/​baselines/​reference/​fourslash/​callHierarchy/​callHierarchyFileNestedWorkspaceRoot.callHierarchy.txt Records nested-root directory handling.
tsc/​testdata/​baselines/​reference/​fourslash/​callHierarchy/​callHierarchyFile.callHierarchy.txt Updates the subdirectory regression baseline.
tsc/​testdata/​baselines/​reference/​fourslash/​callHierarchy/​callHierarchyExportEqualsFunction.callHierarchy.txt Updates source-file module labels.
tsc/​testdata/​baselines/​reference/​fourslash/​callHierarchy/​callHierarchyCallExpressionByConstNamedFunctionExpression.callHierarchy.txt Updates incoming file labels.
tsc/​testdata/​baselines/​reference/​fourslash/​callHierarchy/​callHierarchyAnonymousFunctionNoCrash2.callHierarchy.txt Updates anonymous-function fallback labels.
tsc/​testdata/​baselines/​reference/​fourslash/​callHierarchy/​callHierarchyAnonymousClassNoCrash2.callHierarchy.txt Updates anonymous-class fallback labels.
tsc/​internal/​project/​snapshot.go Exposes workspace folders to the language service.
tsc/​internal/​project/​session.go Adds initial workspace folder metadata.
tsc/​internal/​lsp/​server.go Captures workspace paths and display names during initialization.
tsc/​internal/​ls/​host.go Defines workspace folder metadata and its host accessor.
tsc/​internal/​ls/​file_rename_test.go Updates the test host for the extended interface.
tsc/​internal/​ls/​callhierarchy.go Formats file basenames and workspace-aware directory details.
tsc/​internal/​fourslash/​tests/​callHierarchyFile_test.go Adds subdirectory and workspace regression cases.
tsc/​internal/​fourslash/​fourslash.go Allows tests to supply workspace initialization parameters.

Review effort: Balanced

Comment thread tsc/internal/ls/callhierarchy.go Outdated
if l.CaseSensitivity().ComparePaths(folder.Path.AsPath(), directory.AsPath()) == 0 {
searchDirectory = directory.AsPath().Directory()
}
if l.CaseSensitivity().ContainsPath(folder.Path, searchDirectory.AsPath()) && (containingFolder == nil || len(folder.Path) > len(containingFolder.Path)) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copilot investigate, also why so many AsPaths

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 5e5788f: workspace-folder depth is now determined with case-aware ancestry, with a regression test for the Unicode case-folding scenario. The .AsPath() calls convert RootedDirectoryPath values to the distinct RootedPath type required by the path-comparison APIs; they are type conversions, not repeated path normalization.

Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

On TypeScript 7, Call hierarchy shows a full absolute path instead of file name + relative path

5 participants

⌂ Proxy