@ 261105.2

260308.2 · 57a49d2fbc4d688a2ed9bb52d0524f8d01a3fa3f

fix(win): relative=cursor layout

reading declarations

lua/fzf-lua/win.lua

@@ -612,13 +612,12 @@ function FzfWin:normalize_winopts()     winopts.row = math.floor((winopts.row or 0) + screenpos.row - 1)     winopts.col = math.floor((winopts.col or 0) + screenpos.col - 1)     winopts.relative = nil-  else-    -- make row close to the center of screen (include cmdheight)-    -- avoid breaking existing test-    winopts.row = self:normalize_size(assert(tonumber(winopts.row)), vim.o.lines - winopts.height)-    winopts.col = self:normalize_size(assert(tonumber(winopts.col)), max_width - winopts.width)-    winopts.row = math.min(winopts.row, max_height - winopts.height)   end+  -- make row close to the center of screen (include cmdheight)+  -- avoid breaking existing test+  winopts.row = self:normalize_size(assert(tonumber(winopts.row)), vim.o.lines - winopts.height)+  winopts.col = self:normalize_size(assert(tonumber(winopts.col)), max_width - winopts.width)+  winopts.row = math.min(winopts.row, max_height - winopts.height)   -- width/height can be used for text area   winopts.width = math.max(1, winopts.width - w)   winopts.height = math.max(1, winopts.height - h)

tests/screenshots/tests-win_spec.lua---win---relative=cursor

new file mode 100644@@ -0,0 +1,29 @@+--|---------|---------|---------|---------|---------|---------|----+01|╭──────────foo──────────╮╭────────────────────────╮             +02|│  1 SELECTED FILE: foo ││>                   3/3 │             +03|│                       ││─────────────────────── │             +04|│                       ││▌ foo                   │             +05|│                       ││  bar                   │             +06|│                       ││  baz                   │             +07|│                       ││                        │             +08|│                       ││                        │             +09|│                       ││                        │             +10|│                       ││                        │             +11|│                       ││                        │             +12|│                       ││                        │             +13|│                       ││                        │             +14|│                       ││                        │             +15|│                       ││                        │             +16|│                       ││                        │             +17|│                       ││                        │             +18|│                       ││                        │             +19|│                       ││                        │             +20|╰───────────────────────╯╰────────────────────────╯             +21|~                                                               +22|~                                                               +23|~                                                               +24|[No Name]                                     0,0-1          All+25|                                                                +26|                                                                +27|                                                                +28|-- TERMINAL --                                1,3           All 

tests/screenshots/tests-win_spec.lua---win---relative=cursor-002

new file mode 100644@@ -0,0 +1,29 @@+--|---------|---------|---------|---------|---------|---------|----+01|aaaaaaaaaaaaa╭──────────foo──────────╮╭────────────────────────╮+02|~            │  1 SELECTED FILE: foo ││>                   3/3 │+03|~            │                       ││─────────────────────── │+04|~            │                       ││▌ foo                   │+05|~            │                       ││  bar                   │+06|~            │                       ││  baz                   │+07|~            │                       ││                        │+08|~            │                       ││                        │+09|~            │                       ││                        │+10|~            │                       ││                        │+11|~            │                       ││                        │+12|~            │                       ││                        │+13|~            │                       ││                        │+14|~            │                       ││                        │+15|~            │                       ││                        │+16|~            │                       ││                        │+17|~            │                       ││                        │+18|~            │                       ││                        │+19|~            │                       ││                        │+20|~            ╰───────────────────────╯╰────────────────────────╯+21|~                                                               +22|~                                                               +23|~                                                               +24|[No Name] [+]                                 1,64           All+25|                                                                +26|                                                                +27|                                                                +28|-- TERMINAL --                                1,3           All 

tests/win_spec.lua

@@ -310,6 +310,34 @@ T["win"]["toggle"][""] = new_set(     end   }) +T["win"]["relative=cursor"] = function()+  -- Ignore terminal command line with process number+  local screen_opts = { ignore_text = { 24, 28 }, normalize_paths = helpers.IS_WIN() }+  local opts = {+    __expect_lines = true,+    __screen_opts = screen_opts,+    winopts = {+      relative = "cursor",+      preview = { layout = "horizontal", horizontal = "left:50%" }+    },+    previewer = function() return require("fzf-lua.test.previewer").builtin end,+    __after_open = function()+      child.wait_until(function() return child.lua_get([[_G._fzf_load_called]]) == true end)+      if helpers.IS_WIN() then vim.uv.sleep(250) end+    end,+  }+  helpers.FzfLua.fzf_exec(child, { "foo", "bar", "baz" }, opts)+  child.cmd([[enew]])+  set_lines({ ("a"):rep(child.o.columns) })+  type_keys("g$")+  -- pretend we closed the window to make helpers won't wait for new open+  exec_lua([[_G._fzf_lua_on_create = nil]])+  exec_lua([[_G._fzf_load_called = nil]])+  helpers.FzfLua.fzf_exec(child, { "foo", "bar", "baz" }, opts)+  child.cmd([[bwipe!]])+end++ T["win"]["reuse"] = new_set({   parametrize = {     { {} },