Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: formatting via lsp is broken for another buffer #11

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mityu
Copy link
Contributor

@mityu mityu commented Sep 5, 2024

Problem
When execute lsp format for another buffer, wrong and unexpected textEdit changes may will happen because internal lsp format request is issued with using the current buffer contents.

Reproduce steps

  • Prepare empty a.ts.
  • Prepare this b.ts
function _f(_loooooooooooooongFirstArgument: number, _looooooooooooooongSecondArgument: number, _looooooooooooooooooooongThirdArgument: number) {
}
  • Open Vim/Neovim with deno lsp and lspoint's format extension enabled.
  • Open both a.ts and b.ts, and make b.ts the current buffer: e a.ts, sp b.ts
  • Fire lsp's formatter for a.ts: call denops#notify('lspoints', 'executeCommand', ['format', 'execute', bufnr('a.ts')]).
  • No textEdit changes should be applied since a.ts but, some textEdit changes are requested by deno lsp. (These changes cannot be actually applied for a.ts, so you'll get an error message).
[denops] Error: Failed to call 'executeCommand' API in 'lspoints': Out of range: start character
[denops]     at Plugin.call (file:///Users/mityu/.cache/vim/pack/minpac/opt/denops.vim/denops/@denops-private/service.ts:260:13)
[denops]     at eventLoopTick (ext:core/01_core.js:168:7)
[denops]     at async Service.#dispatch (file:///Users/mityu/.cache/vim/pack/minpac/opt/denops.vim/denops/@denops-private/service.ts:109:12)
[denops]     at async Service.dispatch (file:///Users/mityu/.cache/vim/pack/minpac/opt/denops.vim/denops/@denops-private/service.ts:114:14)
[denops]     at async Vim.#dispatch (file:///Users/mityu/.cache/vim/pack/minpac/opt/denops.vim/denops/@denops-private/host/vim.ts:120:14)

Environment

  • Vim 9.1.708
  • deno 1.45.5

@mityu mityu marked this pull request as draft September 5, 2024 09:56
@mityu
Copy link
Contributor Author

mityu commented Oct 28, 2024

Let's wait for uga-rosa/deno-denops-lsputil#6 to be fixed 👍

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