Skip to content

fix(lsp): attach dartls to the buffer that requested it - #530

Merged
sidlatau merged 1 commit into
mainfrom
fix/lsp-attach-target-buffer
Aug 6, 2026
Merged

fix(lsp): attach dartls to the buffer that requested it#530
sidlatau merged 1 commit into
mainfrom
fix/lsp-attach-target-buffer

Conversation

@sidlatau

@sidlatau sidlatau commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

M.attach() validates the path of the current buffer, but vim.lsp.start() was called without opts, so the client attached to whichever buffer happened to be current when the callback ran. With flutter_lookup_cmd configured that callback is scheduled off a job's output, so switching buffers right after opening a dart file attached dartls to the wrong buffer and left the dart file unattached.

Pass the captured bufnr through, and bail out if the buffer is gone by the time the callback runs.

Also cache the paths resolved via flutter_lookup_cmd, matching the fvm and flutter_path branches. That branch was the only one leaving cached_paths unset, so it re-ran the external lookup command on every attach() - now once per FileType event since #527.

`M.attach()` validates the path of the current buffer, but
`vim.lsp.start()` was called without `opts`, so the client attached to
whichever buffer happened to be current when the callback ran. With
`flutter_lookup_cmd` configured that callback is scheduled off a job's
output, so switching buffers right after opening a dart file attached
dartls to the wrong buffer and left the dart file unattached.

Pass the captured `bufnr` through, and bail out if the buffer is gone by
the time the callback runs.

Also cache the paths resolved via `flutter_lookup_cmd`, matching the
`fvm` and `flutter_path` branches. That branch was the only one leaving
`cached_paths` unset, so it re-ran the external lookup command on every
`attach()` - now once per `FileType` event since #527.
@sidlatau
sidlatau merged commit 3b8e1c5 into main Aug 6, 2026
5 checks passed
@sidlatau
sidlatau deleted the fix/lsp-attach-target-buffer branch August 6, 2026 11:47
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.

1 participant