feat(ui) introducing an lsp menu dialog to fit more features than just codeactions - #2702
feat(ui) introducing an lsp menu dialog to fit more features than just codeactions#2702gat0sy wants to merge 3 commits into
Conversation
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
…actions menu Added resolveContentUriForFileUri() to map LSP file:// responses back to content:// and sftp:// URIs via addedFolder matching Refactor editorManager displayFile/openFile to resolve URIs before opening, enabling cross-workspace go-to-definition and references Added SFTP path-aware root URI resolution for remote workspace context Replace selection menu code-actions button with full LSP actions menu (definition, declaration, implementation, type-definition, references, rename, code-actions) with single-item auto-execution
Greptile SummaryThe PR adds an LSP actions picker with go-to operations and expands URI, client-lifecycle, tooltip-link, and server-initiated workspace-edit handling.
Confidence Score: 3/5The PR is not safe to merge until multi-client action selection and ordered workspace edits are handled without hiding capabilities or dropping edits. The menu can omit valid actions in documents served by multiple LSP clients, while workspace/applyEdit can silently discard earlier edit groups when a document appears more than once. Files Needing Attention: src/lib/selectionMenu.js, src/cm/lsp/definition.ts, src/cm/lsp/transport.ts Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant Menu as LSP Actions Menu
participant Plugin as LSP Client Plugin
participant Server as Language Server
participant Workspace
User->>Menu: Open LSP actions
Menu->>Plugin: Inspect capabilities
User->>Menu: Select action
Menu->>Server: Send textDocument request
Server-->>Menu: Locations or WorkspaceEdit
alt Navigation result
Menu->>Workspace: Open target URI
else workspace/applyEdit
Server->>Workspace: Apply edits by URI
end
Reviews (1): Last reviewed commit: "feat(editor): resolve LSP file:// URIs a..." | Re-trigger Greptile |
| const plugin = LSPPlugin.get(editor); | ||
| if (!plugin) return; | ||
|
|
||
| const capabilities = plugin.client.serverCapabilities || {}; |
There was a problem hiding this comment.
Single-client capability discovery
When multiple language-server clients are attached to a document, this menu reads capabilities from only one plugin, causing actions supported by another client to be omitted; the go-to implementation repeats the same single-client lookup and can reject an otherwise supported action.
Knowledge Base Used: LSP Integration
| const changesByUri: Record<string, TextEdit[]> = | ||
| edit.changes ?? | ||
| Object.fromEntries( | ||
| (edit.documentChanges ?? []) | ||
| .filter((c): c is { textDocument: { uri: string }; edits: TextEdit[] } => "edits" in c) | ||
| .map((c) => [c.textDocument.uri, c.edits]), | ||
| ); |
There was a problem hiding this comment.
Duplicate document edits are dropped
When documentChanges contains multiple entries for the same URI, Object.fromEntries overwrites every earlier edit group with the final one, causing workspace refactors to be only partially applied while the client can still report success.
Knowledge Base Used: LSP Integration
Adds a dedicated LSP actions menu to the editor.
The tooltip button now opens the new LSP menu instead of directly showing code actions. Code actions have been moved into this menu alongside the other go-to actions.
The menu provides quick access to:
Single-result actions are executed directly without opening the menu.
This PR is based on PR #2701