diff options
Diffstat (limited to 'runtime/lua/vim/lsp/util.lua')
-rw-r--r-- | runtime/lua/vim/lsp/util.lua | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua index e95f170427..952926b67e 100644 --- a/runtime/lua/vim/lsp/util.lua +++ b/runtime/lua/vim/lsp/util.lua @@ -193,6 +193,7 @@ function M.get_progress_messages() title = ctx.title or "empty title", message = ctx.message, percentage = ctx.percentage, + done = ctx.done, progress = true, } table.insert(new_messages, new_report) @@ -334,10 +335,12 @@ function M.apply_text_edits(text_edits, bufnr) end if is_cursor_fixed then - vim.api.nvim_win_set_cursor(0, { - cursor.row + 1, - math.min(cursor.col, #(vim.api.nvim_buf_get_lines(bufnr, cursor.row, cursor.row + 1, false)[1] or '')) - }) + local is_valid_cursor = true + is_valid_cursor = is_valid_cursor and cursor.row < vim.api.nvim_buf_line_count(bufnr) + is_valid_cursor = is_valid_cursor and cursor.col <= #(vim.api.nvim_buf_get_lines(bufnr, cursor.row, cursor.row + 1, false)[1] or '') + if is_valid_cursor then + vim.api.nvim_win_set_cursor(0, { cursor.row + 1, cursor.col }) + end end -- Remove final line if needed @@ -951,6 +954,11 @@ end ---@param width (number) window width (in character cells) ---@param height (number) window height (in character cells) ---@param opts (table, optional) +--- - offset_x (number) offset to add to `col` +--- - offset_y (number) offset to add to `row` +--- - border (string or table) override `border` +--- - focusable (string or table) override `focusable` +--- - zindex (string or table) override `zindex`, defaults to 50 ---@returns (table) Options function M.make_floating_popup_options(width, height, opts) validate { @@ -975,7 +983,7 @@ function M.make_floating_popup_options(width, height, opts) else anchor = anchor..'S' height = math.min(lines_above, height) - row = -get_border_size(opts).height + row = 0 end if vim.fn.wincol() + width + (opts.offset_x or 0) <= api.nvim_get_option('columns') then @@ -1124,8 +1132,6 @@ end --- - wrap_at character to wrap at for computing height --- - max_width maximal width of floating window --- - max_height maximal height of floating window ---- - pad_left number of columns to pad contents at left ---- - pad_right number of columns to pad contents at right --- - pad_top number of lines to pad contents at top --- - pad_bottom number of lines to pad contents at bottom --- - separator insert separator after code block @@ -1376,8 +1382,6 @@ end --- - wrap_at character to wrap at for computing height when wrap is enabled --- - max_width maximal width of floating window --- - max_height maximal height of floating window ---- - pad_left number of columns to pad contents at left ---- - pad_right number of columns to pad contents at right --- - pad_top number of lines to pad contents at top --- - pad_bottom number of lines to pad contents at bottom --- - focus_id if a popup with this id is opened, then focus it |