#1305·terax-ai

LSP go-to-definition opens the target file but never moves the cursor to the definition line

Author: SuperYogurtCreated Sep 24, 2026Updated Sep 24, 2026

Terax version

v0.8.6

Operating system

Windows

OS version

Windows 11 25H2 (build 26200)

What happened?

Ctrl+click on a symbol (same with F12) opens the target file, but the cursor is never moved to the definition line. On Windows it also opens a duplicate tab for a file that is already open.

The language server is not at fault. I probed pyright-langserver directly over LSP stdio and asked for the definition of a base class referenced in a subclass declaration (src/pkg/module_a.py:171, class Derived(Base):):

json
{"uri": "file:///d%3A/projects/sample/src/pkg/module_b.py",
 "range": {"start": {"line": 16, "character": 6}}}

Line 16 (0-based) is line 17, exactly where the base class is defined — the server returns the right position.

Tracing the frontend, two issues compound:

1. URI comparison never matches (Windows). pathToFileUri() in src/modules/lsp/lib/uri.ts builds file:///D:/... (uppercase drive letter, literal :), while pyright returns file:///d%3A/... (lowercase drive letter, %3A). The loc.uri === opts.documentUri check in lspInteractions() (src/modules/lsp/lib/client.ts) therefore never matches, so even a definition inside the current file is routed through the cross-file branch.

2. The line number is lost on the cross-file path. fileUriToPath() decodes pyright's URI to d:/projects/sample/src/pkg/module_b.py (lowercase drive letter, forward slashes), while Terax's tab paths are D:\projects\sample\src\pkg\module_b.py (uppercase drive letter, backslashes). openFileTab() in src/modules/tabs/lib/useTabs.ts dedupes with an exact t.path === path comparison, so the already-open file is not reused — a duplicate tab is created instead. On that new-tab path, openContentHit() in src/app/App.tsx does:

typescript
const id = openFileTab(path, true);
if (id == null) return;
const h = editorRefs.current.get(id);
if (h) h.gotoLine(line);
else pendingGotoLine.current.set(id, line);

But openFileTab() computes its return value as a side effect inside the setTabs updater:

typescript
let targetId: number | null = null;
setTabs((curr) => { /* ... */ targetId = existing.id; /* ... */ });
return targetId as number | null;

React 19 only invokes a useState updater synchronously on the eager path (no pending updates on that fiber). Otherwise targetId is still null when the function returns, so gotoLine() is never called and the jump silently degrades to "file opened, cursor unchanged". Even when an id does come back, the line number still has to survive pendingGotoLine → registerEditorHandle() → EditorPane's pendingLineRef / applyPendingGoto() (which waits for doc.status === "ready").

For comparison, CommandPalette calls the very same openContentHit wrapped in runAfterClose(...) — the LSP path has no such deferral.

Note that issue 2 is not Windows-specific: on macOS/Linux the URI comparison succeeds, but a cross-file jump still relies on openFileTab()'s return value, so it can lose the line the same way.

What did you expect to happen?

Ctrl+click / F12 should open the target file (reusing the existing tab when it is already open) and place the cursor on the definition line, scrolled into view.

Steps to reproduce

  1. Windows, Terax v0.8.6, open a Python project.
  2. Enable the Python language server (pyright) for the workspace.
  3. Open a file and Ctrl+click a symbol whose definition lives in another file (e.g. a base class defined in a sibling module).
  4. The target file opens — as a duplicate tab — but the cursor is not moved to the definition line. Jumping again does not help.

Logs / screenshots

The server itself starts correctly (%LOCALAPPDATA%\app.crynta.terax\logs\Terax.log):

[terax_lib::modules::lsp][INFO] lsp spawned id=1 cmd=pyright-langserver root=\\?\D:\projects\sample

The definition response quoted above was captured with a small LSP stdio client (initialize → initialized → didOpen → textDocument/definition) talking to pyright-langserver --stdio directly, so it reflects the server's raw answer without any Terax involvement.

Before submitting

  • I searched existing issues and didn't find a duplicate
  • I am running the latest version (or this happens on main)