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

Merged
merged 1 commit into from
Dec 4, 2024

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 👍

@mityu mityu marked this pull request as ready for review November 21, 2024 08:52
@mityu
Copy link
Contributor Author

mityu commented Nov 21, 2024

Now applyTextEdit() in denops-lsputil is fixed. Ready for review :)

@kuuote
Copy link
Owner

kuuote commented Dec 4, 2024

Thanks and sorry for leave it.

@kuuote kuuote merged commit 6c0355f into kuuote:main Dec 4, 2024
1 check passed
@mityu mityu deleted the fix-lspformat branch December 5, 2024 09:17
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.

2 participants