From 3a6a7add57d2ac141f474b54659bbbf596b76059 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 14 Feb 2023 18:26:22 +0800 Subject: test: remove unused field ext_float (#22243) --- test/functional/ui/screen.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/functional/ui/screen.lua') diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua index 3b9cce0e6f..a059fb5b89 100644 --- a/test/functional/ui/screen.lua +++ b/test/functional/ui/screen.lua @@ -214,7 +214,7 @@ function Screen:attach(options, session) -- simplify test code by doing the same. self._options.rgb = true end - if self._options.ext_multigrid or self._options.ext_float then + if self._options.ext_multigrid then self._options.ext_linegrid = true end end -- cgit From 05faa8f30ad770d4e4ead41cec601ccced8fb97f Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 15 Feb 2023 07:26:55 +0800 Subject: test: make expect_unchanged() less confusing (#22255) Problem: The sleep before collecting the initial screen state is confusing and may lead to unexpected success if it comes after a blocking RPC call. Solution: Remove that sleep and add an "intermediate" argument. --- test/functional/ui/screen.lua | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'test/functional/ui/screen.lua') diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua index a059fb5b89..7760f26fca 100644 --- a/test/functional/ui/screen.lua +++ b/test/functional/ui/screen.lua @@ -470,15 +470,19 @@ screen:redraw_debug() to show all intermediate screen states. ]]) end, expected) end -function Screen:expect_unchanged(waittime_ms, ignore_attrs, request_cb) +function Screen:expect_unchanged(intermediate, waittime_ms, ignore_attrs) waittime_ms = waittime_ms and waittime_ms or 100 -- Collect the current screen state. - self:sleep(0, request_cb) local kwargs = self:get_snapshot(nil, ignore_attrs) - -- Check that screen state does not change. - kwargs.unchanged = true + if intermediate then + kwargs.intermediate = true + else + kwargs.unchanged = true + end + kwargs.timeout = waittime_ms + -- Check that screen state does not change. self:expect(kwargs) end -- cgit From 9b9f8dfcc41ceb80d3970eb58af8ee350b57dc7f Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 18 Feb 2023 09:27:10 +0800 Subject: test: make {MATCH:} behave less unexpectedly in screen:expect() Include the rest of the line and allow multiple {MATCH:} patterns. --- test/functional/ui/screen.lua | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'test/functional/ui/screen.lua') diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua index 7760f26fca..14ce050578 100644 --- a/test/functional/ui/screen.lua +++ b/test/functional/ui/screen.lua @@ -75,6 +75,7 @@ local busted = require('busted') local deepcopy = helpers.deepcopy local shallowcopy = helpers.shallowcopy local concat_tables = helpers.concat_tables +local pesc = helpers.pesc local run_session = helpers.run_session local eq = helpers.eq local dedent = helpers.dedent @@ -257,7 +258,7 @@ local ext_keys = { -- grid: Expected screen state (string). Each line represents a screen -- row. Last character of each row (typically "|") is stripped. -- Common indentation is stripped. --- "{MATCH:x}|" lines are matched against Lua pattern `x`. +-- "{MATCH:x}" in a line is matched against Lua pattern `x`. -- attr_ids: Expected text attributes. Screen rows are transformed according -- to this table, as follows: each substring S composed of -- characters having the same attributes will be substituted by @@ -382,8 +383,20 @@ function Screen:expect(expected, attr_ids, ...) end for i, row in ipairs(expected_rows) do msg_expected_rows[i] = row - local m = (row ~= actual_rows[i] and row:match('{MATCH:(.*)}') or nil) - if row ~= actual_rows[i] and (not m or not (actual_rows[i] and actual_rows[i]:match(m))) then + local pat = nil + if actual_rows[i] and row ~= actual_rows[i] then + local after = row + while true do + local s, e, m = after:find('{MATCH:(.-)}') + if not s then + pat = pat and (pat .. pesc(after)) + break + end + pat = (pat or '') .. pesc(after:sub(1, s - 1)) .. m + after = after:sub(e + 1) + end + end + if row ~= actual_rows[i] and (not pat or not actual_rows[i]:match(pat)) then msg_expected_rows[i] = '*' .. msg_expected_rows[i] if i <= #actual_rows then actual_rows[i] = '*' .. actual_rows[i] -- cgit From d66832c76d6fce1627c33ae60a1b8efec1e32bdd Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 1 Mar 2023 20:16:57 +0800 Subject: test(ui): wait for another success with failure after success Problem: In a success-failure-success situation, if minimal timeout is reached between the failure and the second success, the session is stopped without waiting for the second success, causing the test to fail. Solution: Wait for another success if a failure is seen after a success. Ref #22155 #22464 --- test/functional/ui/screen.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'test/functional/ui/screen.lua') diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua index 14ce050578..e5a449fa66 100644 --- a/test/functional/ui/screen.lua +++ b/test/functional/ui/screen.lua @@ -557,6 +557,7 @@ function Screen:_wait(check, flags) self._session:stop() end elseif success_seen and #args > 0 then + success_seen = false failure_after_success = true -- print(inspect(args)) end -- cgit From fd2ece278b0941ec6673489e88868120e86b834a Mon Sep 17 00:00:00 2001 From: Matthias Deiml Date: Sun, 12 Mar 2023 23:58:46 +0100 Subject: feat(ui): add scroll_delta to win_viewport event #19270 scroll_delta contains how much the top line of a window moved since the last time win_viewport was emitted. It is expected to be used to implement smooth scrolling. For this purpose it only counts "virtual" or "displayed" so folds should count as one line. Because of this it adds extra information that cannot be computed from the topline parameter. Fixes #19227 --- test/functional/ui/screen.lua | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'test/functional/ui/screen.lua') diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua index e5a449fa66..f5ae9c8e89 100644 --- a/test/functional/ui/screen.lua +++ b/test/functional/ui/screen.lua @@ -803,14 +803,17 @@ function Screen:_handle_win_pos(grid, win, startrow, startcol, width, height) self.float_pos[grid] = nil end -function Screen:_handle_win_viewport(grid, win, topline, botline, curline, curcol, linecount) +function Screen:_handle_win_viewport(grid, win, topline, botline, curline, curcol, linecount, scroll_delta) + -- accumulate scroll delta + local last_scroll_delta = self.win_viewport[grid] and self.win_viewport[grid].sum_scroll_delta or 0 self.win_viewport[grid] = { win = win, topline = topline, botline = botline, curline = curline, curcol = curcol, - linecount = linecount + linecount = linecount, + sum_scroll_delta = scroll_delta + last_scroll_delta } end @@ -1348,7 +1351,7 @@ local function fmt_ext_state(name, state) for k,v in pairs(state) do str = (str.." ["..k.."] = {win = {id = "..v.win.id.."}, topline = " ..v.topline..", botline = "..v.botline..", curline = "..v.curline - ..", curcol = "..v.curcol..", linecount = "..v.linecount.."};\n") + ..", curcol = "..v.curcol..", linecount = "..v.linecount..", scroll_delta = "..v.scroll_delta.."};\n") end return str .. "}" elseif name == "float_pos" then -- cgit From 0f1e2b6686694d878795fa090d4a08ba0f8acb4d Mon Sep 17 00:00:00 2001 From: bfredl Date: Mon, 13 Mar 2023 20:38:21 +0100 Subject: fix(screen): redraw the ruler for a current floating window Semi-regression. The "ruler" behavior for a floating window was never really specified but in practice followed the users cursor movements in normal mode in a focused float, which seems like a reasonable behavior to now specify. --- test/functional/ui/screen.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/functional/ui/screen.lua') diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua index f5ae9c8e89..83424d3bea 100644 --- a/test/functional/ui/screen.lua +++ b/test/functional/ui/screen.lua @@ -1351,7 +1351,7 @@ local function fmt_ext_state(name, state) for k,v in pairs(state) do str = (str.." ["..k.."] = {win = {id = "..v.win.id.."}, topline = " ..v.topline..", botline = "..v.botline..", curline = "..v.curline - ..", curcol = "..v.curcol..", linecount = "..v.linecount..", scroll_delta = "..v.scroll_delta.."};\n") + ..", curcol = "..v.curcol..", linecount = "..v.linecount..", sum_scroll_delta = "..v.sum_scroll_delta.."};\n") end return str .. "}" elseif name == "float_pos" then -- cgit From fdc8e966a9183c08f2afec0817d03b7417a883b3 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 4 Jun 2023 10:49:02 +0800 Subject: fix(ui): don't send empty grid_line with redrawdebug=compositor (#23899) --- test/functional/ui/screen.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'test/functional/ui/screen.lua') diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua index 83424d3bea..2307fd106b 100644 --- a/test/functional/ui/screen.lua +++ b/test/functional/ui/screen.lua @@ -947,6 +947,7 @@ end function Screen:_handle_grid_line(grid, row, col, items) assert(self._options.ext_linegrid) + assert(#items > 0) local line = self._grids[grid].rows[row+1] local colpos = col+1 local hl_id = 0 -- cgit From f5953edbac14febce9d4f8a3c35bdec1eae26fbe Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 14 Sep 2023 07:42:22 +0800 Subject: fix(float): update position of anchored windows first (#25133) --- test/functional/ui/screen.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/functional/ui/screen.lua') diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua index 2307fd106b..be7c2f291c 100644 --- a/test/functional/ui/screen.lua +++ b/test/functional/ui/screen.lua @@ -1270,7 +1270,7 @@ end function Screen:render(headers, attr_state, preview) headers = headers and (self._options.ext_multigrid or self._options._debug_float) local rv = {} - for igrid,grid in pairs(self._grids) do + for igrid,grid in vim.spairs(self._grids) do if headers then local suffix = "" if igrid > 1 and self.win_position[igrid] == nil -- cgit From f96f8566b5f7997266264ba94a22844d9bc22699 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 9 Oct 2023 16:14:37 +0800 Subject: test(ui/embed_spec): use notification instead of request (#25555) This avoid the hang mentioned in #24888, and also matches TUI better. --- test/functional/ui/screen.lua | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'test/functional/ui/screen.lua') diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua index be7c2f291c..d3ffb07749 100644 --- a/test/functional/ui/screen.lua +++ b/test/functional/ui/screen.lua @@ -150,6 +150,7 @@ function Screen.new(width, height) msg_grid = nil, msg_grid_pos = nil, _session = nil, + rpc_async = false, messages = {}, msg_history = {}, showmode = {}, @@ -173,9 +174,13 @@ function Screen.new(width, height) _busy = false, }, Screen) local function ui(method, ...) - local status, rv = self._session:request('nvim_ui_'..method, ...) - if not status then - error(rv[2]) + if self.rpc_async then + self._session:notify('nvim_ui_'..method, ...) + else + local status, rv = self._session:request('nvim_ui_'..method, ...) + if not status then + error(rv[2]) + end end end self.uimeths = create_callindex(ui) -- cgit From 448907f65d6709fa234d8366053e33311a01bdb9 Mon Sep 17 00:00:00 2001 From: LW Date: Sun, 12 Nov 2023 04:54:27 -0800 Subject: feat(lsp)!: vim.lsp.inlay_hint.get(), enable(), is_enabled() #25512 refactor!: `vim.lsp.inlay_hint()` -> `vim.lsp.inlay_hint.enable()` Problem: The LSP specification allows inlay hints to include tooltips, clickable label parts, and code actions; but Neovim provides no API to query for these. Solution: Add minimal viable extension point from which plugins can query for inlay hints in a range, in order to build functionality on top of. Possible Next Steps --- - Add `virt_text_idx` field to `vim.fn.getmousepos()` return value, for usage in mappings of ``, ``, etc --- test/functional/ui/screen.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'test/functional/ui/screen.lua') diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua index d3ffb07749..810a68d387 100644 --- a/test/functional/ui/screen.lua +++ b/test/functional/ui/screen.lua @@ -88,6 +88,7 @@ local function isempty(v) return type(v) == 'table' and next(v) == nil end +--- @class test.functional.ui.screen local Screen = {} Screen.__index = Screen -- cgit