Skip to content

feat(lsp): add go-to actions and improve client lifecycle - #2701

Open
gat0sy wants to merge 3 commits into
Acode-Foundation:mainfrom
gat0sy:feat/lsp-features
Open

feat(lsp): add go-to actions and improve client lifecycle#2701
gat0sy wants to merge 3 commits into
Acode-Foundation:mainfrom
gat0sy:feat/lsp-features

Conversation

@gat0sy

@gat0sy gat0sy commented Aug 8, 2026

Copy link
Copy Markdown

Adds Go to Definition, Declaration, Type Definition, and Implementation to the LSP features.

  • Adds a 45s grace period before disposing idle clients to avoid reinitialization races
  • Normalizes SFTP URIs before sending them to LSP servers
  • Refactors textEditUtils imports where lspPositionToOffset is needed

This PR is based on PR #2700

@greptile-apps

greptile-apps Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR adds go-to navigation, delays disposal of idle LSP clients, normalizes SFTP document URIs, and introduces handling for server-pushed workspace edits. The repeated-edit fix retains every entry but does not preserve sequential same-document edit semantics.

  • Adds definition, declaration, implementation, and type-definition navigation.
  • Adds a 45-second idle-client grace period and updates initialization behavior.
  • Centralizes text-edit conversion and handles workspace/applyEdit requests.
  • Intercepts file links in hover and signature documentation.

Confidence Score: 4/5

The PR is not yet safe to merge because repeated same-document workspace edits can be applied against the wrong document snapshot.

The workspace/applyEdit fix preserves repeated entries by concatenating them, but converting and dispatching all ranges against one pre-edit document loses the ordered state transitions required by later entries.

Files Needing Attention: src/cm/lsp/transport.ts, src/cm/lsp/textEditUtils.ts

Important Files Changed

Filename Overview
src/cm/lsp/transport.ts Adds workspace/applyEdit handling and retains repeated same-URI entries, but flattens ordered document changes into one snapshot-based transaction.
src/cm/lsp/textEditUtils.ts Centralizes LSP position conversion and edit dispatch; its single-transaction behavior exposes the repeated-entry ordering defect.
src/cm/lsp/clientManager.ts Changes client initialization, root handling, SFTP URI normalization, and delayed idle disposal without an accepted blocking finding.
src/cm/lsp/definition.ts Introduces go-to navigation requests and references-panel integration without an accepted blocking finding.
src/cm/lsp/tooltipExtensions.ts Adds interception of file links in hover and signature tooltips without an eligible accepted finding.

Sequence Diagram

sequenceDiagram
  participant Server as LSP Server
  participant Transport as workspace/applyEdit handler
  participant Utils as applyTextEdits
  participant Editor as CodeMirror Editor
  Server->>Transport: documentChanges entry 1 for URI
  Server->>Transport: documentChanges entry 2 for same URI
  Transport->>Transport: Concatenate both edit arrays
  Transport->>Utils: Apply combined edits
  Utils->>Utils: Resolve every range against syncedDoc
  Utils->>Editor: Dispatch one transaction
  Note over Utils,Editor: Later-entry ranges do not see entry 1's resulting state
Loading

Reviews (2): Last reviewed commit: "feat(lsp): add go-to-definition, code ac..." | Re-trigger Greptile

Comment thread src/cm/lsp/transport.ts Outdated
gat0sy added 3 commits August 10, 2026 03:38
LspToPosition threw range error on format error.
We attempt to fix it here with by clamping so we get the correct line count between the client and server.

applyTextEdit as also been extracted so both transport and client manager can import it from the helper.
LspToPosition threw range error on format error.
We attempt to fix it here with by clamping so we get the correct line count between the client and server.

applyTextEdit as also been extracted so both transport and client manager can import it from the helper.
go to def and similar fonction have been added,
a new interceptFileLink method has been created to solve an FileUriExposedException you may get if taping the signature link on the hover.

if the link is a website, it skips and let the normal behavior occur ( open a web browser page )
if the link is a file, it modifies the uri so the tap behave like a go to instead of crashing the whole app.
There are notably also some fixes for code actions, rename...ect, now they use the new lspPostionToOffset that uses clamping
@gat0sy
gat0sy force-pushed the feat/lsp-features branch from 2e7c60b to 8a7ce5b Compare August 10, 2026 04:38
@bajrangCoder

This comment was marked as outdated.

Comment thread src/cm/lsp/transport.ts
Comment on lines +200 to +205
if (edit.documentChanges) {
for (const change of edit.documentChanges) {
if ("edits" in change) {
const uri = change.textDocument.uri;
changesByUri[uri] = [...(changesByUri[uri] ?? []),
...change.edits];

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.

P1 Sequential document edits share stale positions

When a server sends multiple ordered documentChanges entries for the same URI and a later entry uses the document state produced by an earlier entry, this code concatenates them and resolves every range against the same plugin.syncedDoc. The later edit therefore modifies the wrong text or overlaps an earlier change and causes the workspace-edit transaction to fail.

Knowledge Base Used: LSP Integration

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

Labels

enhancement New feature or request

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

2 participants