Skip to content

Go to the code behind an interface with Go to implementation (gi) - #701

Merged
jamescrosswell merged 3 commits into
mainfrom
feat/go-to-implementation
Nov 20, 2026
Merged

jamescrosswell merged 3 commits into
mainfrom
feat/go-to-implementation

Conversation

@a-team-app

@a-team-app a-team-app Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

In a C# file you can now go from a call through an interface to the code that actually runs. Go to implementation (Ctrl+G I, mnemonic gi, Go menu) jumps to the only implementation, or opens a picker titled Implementations of IShape.Area when there are several. On an interface name it lists the classes that implement it. If nothing implements it, the status bar says No implementations of ILogger.Log. Implementations that live in a referenced library open as read-only decompiled source, the same way Go to definition's do.

Closes #699

Choices worth flagging:

  • Quick info moved to Ctrl+G Q / qi. In the leader, q now waits and lists q and qi: q Enter quits and qi opens Quick info. Every other mnemonic still runs as soon as you type it. q waits even where Quick info isn't offered (in the Explorer, say), so the key you have to press doesn't change depending on where you are.
  • csharp-ls 0.28 answers an interface member nothing implements with the member's own declaration. I treat a single answer that is the declaration itself as "no implementations". For an ordinary non-virtual method this also means gi says there are none rather than jumping to the method itself. Go to definition already does that jump.
  • A server that doesn't advertise implementationProvider is never asked. The status bar says <server> can't find implementations. The name is the one TuiCode knows the server by, so Pyright shows as Pyright; only a server TuiCode doesn't know is named by its own serverInfo.name. I couldn't run Pyright here, so only a test covers that message.
  • For IComparable<int>.CompareTo, csharp-ls returns every BCL type that implements IComparable<T> (79 places in 39 files), and the picker takes about 7 s to open on that query. Most of that is the server's own answer.

🤖 Generated with Claude Code

What it looks like

In a C# file, on a call through an interface method with one implementation, Ctrl+G I puts the cursor on that implementation, unfolded and below any sticky lines, and Ctrl+G P comes back.

In a C# file, on a call through an interface method with one implementation, Ctrl+G I puts the cursor on that implementation, unfolded and below any sticky lines, and Ctrl+G P comes back.

In a C# file, on a call through an interface method with one implementation, Ctrl+G I puts the cursor on that implementation, unfolded and below any sticky lines, and Ctrl+G P comes back.

In a C# file, on a call through an interface method with one implementation, Ctrl+G I puts the cursor on that implementation, unfolded and below any sticky lines, and Ctrl+G P comes back.

On an interface method with two or more implementations, Ctrl+G I opens a picker titled Implementations of <Type>.<Member>, with a Filter text field and one row per implementation (File.cs:12 code on that line). Enter or the Go to button goes to the selected row; Esc or Cancel leaves the cursor where it was.

On an interface method with two or more implementations, Ctrl+G I opens a picker titled Implementations of <Type>.<Member>, with a Filter text field and one row per implementation (File.cs:12  code on that line). Enter or the Go to button goes to the selected row; Esc or Cancel leaves the cursor where it was.

On an interface type name, Ctrl+G I lists or jumps to the classes that implement it.

On an interface type name, Ctrl+G I lists or jumps to the classes that implement it.

Where nothing implements it, the status bar says No implementations of <name>.

Where nothing implements it, the status bar says No implementations of <name>.

An implementation that lives in a referenced library opens as read-only decompiled source, as Go to definition's do.

An implementation that lives in a referenced library opens as read-only decompiled source, as Go to definition's do.

The Go menu lists Go to implementation beside Go to definition with its Ctrl+G I hint, and the F1 help lists it.

The Go menu lists Go to implementation beside Go to definition with its Ctrl+G I hint, and the F1 help lists it.

Quick info now opens with Ctrl+G Q and the mnemonic qi; its Go menu item has hotkey Q and shows Ctrl+G Q, and its F1 row says the same.

Quick info now opens with Ctrl+G Q and the mnemonic qi; its Go menu item has hotkey Q and shows Ctrl+G Q, and its F1 row says the same.

In the leader, typing q alone no longer quits at once: it waits, listing q and qi. q Enter quits; qi opens Quick info.

In the leader, typing q alone no longer quits at once: it waits, listing q and qi. q Enter quits; qi opens Quick info.

Checked by the team

  • screen In a C# file, on a call through an interface method with one implementation, Ctrl+G I puts the cursor on that implementation, unfolded and below any sticky lines, and Ctrl+G P comes back.
  • test Typing the mnemonic gi in the leader does the same.
  • screen On an interface method with two or more implementations, Ctrl+G I opens a picker titled Implementations of <Type>.<Member>, with a Filter text field and one row per implementation (File.cs:12 code on that line). Enter or the Go to button goes to the selected row; Esc or Cancel leaves the cursor where it was.
  • screen On an interface type name, Ctrl+G I lists or jumps to the classes that implement it.
  • screen Where nothing implements it, the status bar says No implementations of <name>.
  • screen An implementation that lives in a referenced library opens as read-only decompiled source, as Go to definition's do.
  • test In a Python file served by Pyright, the status bar says Pyright can't find implementations instead of reporting none.
  • test With no language server, or while one is still starting, Ctrl+G I says what Ctrl+G D says, and the Go menu dims Go to implementation as it dims Go to definition.
  • screen The Go menu lists Go to implementation beside Go to definition with its Ctrl+G I hint, and the F1 help lists it.
  • screen Quick info now opens with Ctrl+G Q and the mnemonic qi; its Go menu item has hotkey Q and shows Ctrl+G Q, and its F1 row says the same.
  • screen In the leader, typing q alone no longer quits at once: it waits, listing q and qi. q Enter quits; qi opens Quick info.
  • test Every other mnemonic still runs as soon as it's typed, without Enter.

a-team try tuicode 701

a-team-app Bot and others added 2 commits November 19, 2026 21:16
Go to definition stops at an interface or abstract declaration. Go to
implementation asks the language server for textDocument/implementation and
routes the answer as Go to definition does: one jumps, several open the picker
titled "Implementations of <Type>.<Member>", decompiled library places
included. A server whose initialize result lacks implementationProvider, such
as Pyright, is never asked, and the status bar says it can't find them.
csharp-ls answers an unimplemented member with its own declaration, so that
is left out and the status bar says there are none.

Quick info moves to qi / Ctrl+G Q. In the leader, Enter now runs a complete
mnemonic that a longer one starts with, so q waits and q Enter quits; every
other mnemonic still runs as it's typed. The resolver is handed the whole
table so q waits even where qi isn't offered.

Closes #699

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Asked for the implementations of an interface member nothing implements,
csharp-ls 0.28 answers with the member's own declaration, so gi jumped back
to the interface instead of saying there are none. A single answer that is
the definition the name comes from now counts as none. The fake server
answers the same way, so the "nothing implements it" test covers it.

Closes #699

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@a-team-app

a-team-app Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor Author

Needs changing

  • The first picture in What it looks like doesn't show what its caption says. The caption claims the jump lands below any sticky lines and that Ctrl+G P comes back, but the picture is only the arrival in SystemClock.cs, a 6-line file with no sticky lines and no return trip. Either recapture it in a longer file and add a second shot after Ctrl+G P, or caption it for what it shows. The host test proves the behaviour, but the criterion is marked screen.

Worth considering

  • src/TuiCode.Workbench/Languages/LanguageServer.cs:148 uses the server's serverInfo.name ahead of the Title TuiCode curates in KnownLanguageServers, so the Pyright message depends on a name that hasn't been checked against a real Pyright. If it gives pyright, or nothing useful, the criterion's Pyright can't find implementations breaks. Using the known Title first and serverInfo.name only for servers TuiCode doesn't know would make the message deterministic.
  • ImplementationsAsync (WorkbenchHost.cs, below GoToImplementation) waits for textDocument/implementation, then definition, then documentSymbol, one after the other, even when the answer is a single jump that never uses the name. Starting the definition request alongside the implementation request would cut a round trip from every gi, which matters given the 7 s IComparable<int>.CompareTo case.
  • gi reuses _definitionRequest, so pressing gd and then gi before the first answer comes back drops the gd answer. That's probably right ("latest request wins"), but it isn't written down or tested, and a separate counter would make it a choice rather than a side effect.

@a-team-app

a-team-app Bot commented Nov 19, 2026

Copy link
Copy Markdown
Contributor Author

Review answered:

Needs changing

  1. Fixed. I retook the first picture in a 128-line SystemClock.cs inside namespace Demo.Time { public class SystemClock … }. After Ctrl+G I on clock.Now(), the cursor is on line 66, below the sticky public class SystemClock : IClock line. A second picture, after Ctrl+G P, shows the cursor back on Program.cs line 7, col 25. No code changed.

Worth considering: I've left all three for you. Say if you want any of them done.

@jamescrosswell

Copy link
Copy Markdown
Contributor

src/TuiCode.Workbench/Languages/LanguageServer.cs:148 uses the server's serverInfo.name ahead of the Title TuiCode curates in KnownLanguageServers, so the Pyright message depends on a name that hasn't been checked against a real Pyright. If it gives pyright, or nothing useful, the criterion's Pyright can't find implementations breaks. Using the known Title first and serverInfo.name only for servers TuiCode doesn't know would make the message deterministic.

ImplementationsAsync (WorkbenchHost.cs, below GoToImplementation) waits for textDocument/implementation, then definition, then documentSymbol, one after the other, even when the answer is a single jump that never uses the name. Starting the definition request alongside the implementation request would cut a round trip from every gi, which matters given the 7 s IComparable<int>.CompareTo case.

Please fix these.

…e implementations

The status bar uses KnownLanguageServers' title for a server TuiCode knows,
and serverInfo.name only for one it doesn't, so "Pyright can't find
implementations" no longer depends on what Pyright calls itself.

gi now sends textDocument/definition alongside textDocument/implementation
instead of after it, and skips documentSymbol when the answer is a single jump
that never shows the name.

Closes #699

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@a-team-app

a-team-app Bot commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

Both fixed in 259bc6b.

  • Title: a server TuiCode knows now always shows the title from KnownLanguageServers, so the message reads Pyright can't find implementations whatever Pyright calls itself. serverInfo.name is used only for a custom server. Tests cover both cases.
  • Round trip: gi now sends definition alongside implementation, and skips documentSymbol when the answer is a single jump that never shows the name. A new host test holds back the implementation answer and checks that the definition request still goes out.

@jamescrosswell
jamescrosswell merged commit d588308 into main Nov 20, 2026
44 of 45 checks passed
@jamescrosswell
jamescrosswell deleted the feat/go-to-implementation branch November 20, 2026 10:19
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.

Go to the code that runs behind an interface with Go to implementation (gi)

1 participant