fix(lsp): respect range in linewise visual mode #41636

Problem:
An explicitly passed `range` to `vim.lsp.buf.format()` in linewise
visual mode is silently replaced by the selection.

Solution:
Parenthesise the mode check.
This commit is contained in:
Volodymyr Chernetskyi authored and GitHub committed 2026-09-02 17:01:32 -04:00
1 parent 10fa98bb6e
commit a58cee4512
1 file changed
+1 -1
+1 -1
View File
@@ -631,7 +631,7 @@ function M.format(opts)
local mode = api.nvim_get_mode().mode
local range = opts.range
-- Try to use visual selection if no range is given
if not range and mode == 'v' or mode == 'V' then
if not range and (mode == 'v' or mode == 'V') then
range = range_from_selection(bufnr, mode)
end