From: Andreas Louv Date: Sun, 12 Mar 2023 22:41:09 +0000 (+0100) Subject: Send charcol when requesting code action X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=9bfc355e453539d3f2c738f1d10576b8fd60fb39;p=vim-lsp.git Send charcol when requesting code action The typescript-language-server will provide better code actions when knowing which column you stand on. For instance the "add missing import" action works more reliable when the server knows the current column. --- diff --git a/autoload/lsp/lspserver.vim b/autoload/lsp/lspserver.vim index f0397c8..81bb8c1 100644 --- a/autoload/lsp/lspserver.vim +++ b/autoload/lsp/lspserver.vim @@ -1342,8 +1342,15 @@ def CodeAction(lspserver: dict, fname_arg: string, line1: number, var fname: string = fname_arg->fnamemodify(':p') var bnr: number = fname_arg->bufnr() var r: dict> = { - start: {line: line1 - 1, character: 0}, - end: {line: line2 - 1, character: charcol([line2, '$']) - 1}} + start: { + line: line1 - 1, + character: line1 == line2 ? charcol('.') - 1 : 0 + }, + end: { + line: line2 - 1, + character: charcol([line2, '$']) - 1 + } + } params->extend({textDocument: {uri: util.LspFileToUri(fname)}, range: r}) var d: list> = [] for lnum in range(line1, line2)