Skip to content

Commit ce5a5fa

Browse files
phanenibhagwan
authored andcommitted
fix(win): ensure fzf have the same list height
fzf's previewer border is draw inside preview window, so shrink builtin previewer if it have "top border"
1 parent b124e26 commit ce5a5fa

18 files changed

Lines changed: 114 additions & 110 deletions

lua/fzf-lua/win.lua

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,10 @@ function FzfWin:generate_layout()
334334
pwopts.col = col
335335
pwopts.width = width
336336
-- https://github.com/junegunn/fzf/blob/1afd14381079a35eac0a4c2a5cacb86e2a3f476b/src/terminal.go#L1820
337-
pwopts.height = math.floor(height * preview_size / 100)
337+
-- fzf's previewer border is draw inside preview window, so shrink builtin previewer if it have "top border"
338+
-- to ensure the fzf list height is the same between fzf/builtin
339+
local off = (self.previewer_is_builtin and ph > 0) and 1 or 0
340+
pwopts.height = math.floor((height + off) * preview_size / 100) - off
338341
height = height - pwopts.height
339342
if preview_pos == "down" then
340343
-- next row
@@ -349,7 +352,8 @@ function FzfWin:generate_layout()
349352
else -- left|right
350353
pwopts.row = row
351354
pwopts.height = height
352-
pwopts.width = math.floor(width * preview_size / 100)
355+
local off = (self.previewer_is_builtin and pw > 0) and 1 or 0
356+
pwopts.width = math.floor((width + off) * preview_size / 100) - off
353357
width = width - pwopts.width
354358
if preview_pos == "right" then
355359
-- next col

tests/screenshots/tests-actions_spec.lua---actions---vimcmd---1-+-args-{-'drop'-}

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@
1111
10|n the r│ │
1212
11|to use,│ │se, an
1313
12|d/or se│ │
14-
13|copies ╰─────────────────────────────────────────────────╯Softwa
15-
14|re is ──────────────────── LICENSE ────────────────────
16-
15|furnish│ 1 MIT License
17-
16| │ 2
18-
17|The abo│ 3 Copyright (c) 2021 iBhagwan l be i
19-
18|ncluded│ 4
20-
19|copies │ 5 Permission is hereby granted, free of charge,
21-
20| │ 6 of this software and associated documentation
22-
21|THE SOF│ 7 in the Software without restriction, includin│KIND,
14+
13|copies │ │Softwa
15+
14|re is ─────────────────────────────────────────────────╯
16+
15|furnish╭──────────────────── LICENSE ────────────────────╮
17+
16| │ 1 MIT License
18+
17|The abo│ 2 l be i
19+
18|ncluded│ 3 Copyright (c) 2021 iBhagwan
20+
19|copies │ 4
21+
20| │ 5 Permission is hereby granted, free of charge,
22+
21|THE SOF│ 6 of this software and associated documentation│KIND,
2323
22|EXPRESS╰─────────────────────────────────────────────────╯
2424
23|IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCH@@@
2525
24|LICENSE 1,1 Top

tests/screenshots/tests-actions_spec.lua---actions---vimcmd---1-+-args-{-'file_edit'-}

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@
1111
10|n the r│ │
1212
11|to use,│ │se, an
1313
12|d/or se│ │
14-
13|copies ╰─────────────────────────────────────────────────╯Softwa
15-
14|re is ──────────────────── LICENSE ────────────────────
16-
15|furnish│ 1 MIT License
17-
16| │ 2
18-
17|The abo│ 3 Copyright (c) 2021 iBhagwan l be i
19-
18|ncluded│ 4
20-
19|copies │ 5 Permission is hereby granted, free of charge,
21-
20| │ 6 of this software and associated documentation
22-
21|THE SOF│ 7 in the Software without restriction, includin│KIND,
14+
13|copies │ │Softwa
15+
14|re is ─────────────────────────────────────────────────╯
16+
15|furnish╭──────────────────── LICENSE ────────────────────╮
17+
16| │ 1 MIT License
18+
17|The abo│ 2 l be i
19+
18|ncluded│ 3 Copyright (c) 2021 iBhagwan
20+
19|copies │ 4
21+
20| │ 5 Permission is hereby granted, free of charge,
22+
21|THE SOF│ 6 of this software and associated documentation│KIND,
2323
22|EXPRESS╰─────────────────────────────────────────────────╯
2424
23|IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCH@@@
2525
24|LICENSE 1,1 Top

tests/screenshots/tests-actions_spec.lua---actions---vimcmd---1-+-args-{-'file_open_in_background'-}

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@
1111
10|~ │ │
1212
11|~ │ │
1313
12|~ │ │
14-
13|~ ╰─────────────────────────────────────────────────╯
15-
14|~ ──────────────────── LICENSE ────────────────────
16-
15|~ │ 1 MIT License
17-
16|~ │ 2
18-
17|~ │ 3 Copyright (c) 2021 iBhagwan
19-
18|~ │ 4
20-
19|~ │ 5 Permission is hereby granted, free of charge,
21-
20|~ │ 6 of this software and associated documentation
22-
21|~ │ 7 in the Software without restriction, includin
14+
13|~ │ │
15+
14|~ ─────────────────────────────────────────────────╯
16+
15|~ ╭──────────────────── LICENSE ────────────────────╮
17+
16|~ │ 1 MIT License
18+
17|~ │ 2
19+
18|~ │ 3 Copyright (c) 2021 iBhagwan
20+
19|~ │ 4
21+
20|~ │ 5 Permission is hereby granted, free of charge,
22+
21|~ │ 6 of this software and associated documentation
2323
22|~ ╰─────────────────────────────────────────────────╯
2424
23|~
2525
24|[No Name] 0,0-1 All

tests/screenshots/tests-actions_spec.lua---actions---vimcmd---1-+-args-{-'file_split'-}

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@
1111
10|n the r│ │
1212
11|to use,│ │se,@@@
1313
12|LICENSE│ │ Top
14-
13| ╰─────────────────────────────────────────────────╯
15-
14|~ ──────────────────── LICENSE ────────────────────
16-
15|~ │ 1 MIT License
17-
16|~ │ 2
18-
17|~ │ 3 Copyright (c) 2021 iBhagwan
19-
18|~ │ 4
20-
19|~ │ 5 Permission is hereby granted, free of charge,
21-
20|~ │ 6 of this software and associated documentation
22-
21|~ │ 7 in the Software without restriction, includin
14+
13| │ │
15+
14|~ ─────────────────────────────────────────────────╯
16+
15|~ ╭──────────────────── LICENSE ────────────────────╮
17+
16|~ │ 1 MIT License
18+
17|~ │ 2
19+
18|~ │ 3 Copyright (c) 2021 iBhagwan
20+
19|~ │ 4
21+
20|~ │ 5 Permission is hereby granted, free of charge,
22+
21|~ │ 6 of this software and associated documentation
2323
22|~ ╰─────────────────────────────────────────────────╯
2424
23|~
2525
24|[No Name] 0,0-1 All

tests/screenshots/tests-actions_spec.lua---actions---vimcmd---1-+-args-{-'file_tabedit'-}

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@
1111
10|in the │ │itatio
1212
11|n the r│ │
1313
12|to use,│ │se, an
14-
13|d/or se╰─────────────────────────────────────────────────╯
15-
14|copies ──────────────────── LICENSE ────────────────────Softwa
16-
15|re is │ 1 MIT License
17-
16|furnish│ 2
18-
17| │ 3 Copyright (c) 2021 iBhagwan
19-
18|The abo│ 4 │l be i
20-
19|ncluded│ 5 Permission is hereby granted, free of charge,
21-
20|copies │ 6 of this software and associated documentation
22-
21| │ 7 in the Software without restriction, includin
14+
13|d/or se│ │
15+
14|copies ─────────────────────────────────────────────────╯Softwa
16+
15|re is ╭──────────────────── LICENSE ────────────────────╮
17+
16|furnish│ 1 MIT License
18+
17| │ 2
19+
18|The abo│ 3 Copyright (c) 2021 iBhagwan │l be i
20+
19|ncluded│ 4
21+
20|copies │ 5 Permission is hereby granted, free of charge,
22+
21| │ 6 of this software and associated documentation
2323
22|THE SOF╰─────────────────────────────────────────────────╯KIND,
2424
23|EXPRESS OR
2525
24|LICENSE 1,1 Top

tests/screenshots/tests-actions_spec.lua---actions---vimcmd---1-+-args-{-'file_vsplit'-}

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@
1111
10|re"), t│ │
1212
11|in the │ │
1313
12|ion, in│ │
14-
13|n the r╰─────────────────────────────────────────────────╯
15-
14|to use,──────────────────── LICENSE ────────────────────
16-
15|lish, d│ 1 MIT License
17-
16|d/or se│ 2
18-
17|copies │ 3 Copyright (c) 2021 iBhagwan
19-
18|ermit p│ 4
20-
19|re is │ 5 Permission is hereby granted, free of charge,
21-
20|furnish│ 6 of this software and associated documentation
22-
21|he foll│ 7 in the Software without restriction, includin
14+
13|n the r│ │
15+
14|to use,─────────────────────────────────────────────────╯
16+
15|lish, d╭──────────────────── LICENSE ────────────────────╮
17+
16|d/or se│ 1 MIT License
18+
17|copies │ 2
19+
18|ermit p│ 3 Copyright (c) 2021 iBhagwan
20+
19|re is │ 4
21+
20|furnish│ 5 Permission is hereby granted, free of charge,
22+
21|he foll│ 6 of this software and associated documentation
2323
22| ╰─────────────────────────────────────────────────╯
2424
23|The above copyright notice an@@@│~
2525
24|LICENSE 1,1 Top [No Name] 0,0-1 All

tests/screenshots/tests-files_spec.lua---files---line_query

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
10|~ │ │
1212
11|~ │ │
1313
12|~ │ │
14-
13|~ ╰─────────────────────────────────────────────────╯
15-
14|~ ──────────────────── LICENSE ────────────────────
16-
15|~ │ 15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WAR│
14+
13|~ │ │
15+
14|~ ─────────────────────────────────────────────────╯
16+
15|~ ╭──────────────────── LICENSE ────────────────────╮
1717
16|~ │ 16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WAR│
1818
17|~ │ 17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRI│
1919
18|~ │ 18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR AN│
20-
19|~ │ 19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20+
19|~ │ 19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
2121
20|~ │ 20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
2222
21|~ │ 21 SOFTWARE.
2323
22|~ ╰─────────────────────────────────────────────────╯

tests/screenshots/tests-files_spec.lua---files---preview-should-work-after-chdir-#1864

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@
1111
10|~ │ README.md │
1212
11|~ │ autoload/fzf_lua.vim │
1313
12|~ │ autoload/health/fzf_lua.vim │
14-
13|~ ╰─────────────────────────────────────────────────╯
15-
14|~ ─────────────────── Makefile ────────────────────
16-
15|~ │ 1 nvim ?= nvim
17-
16|~ │ 2
18-
17|~ │ 3 #
19-
18|~ │ 4 # Run all tests or specic module tests
20-
19|~ │ 5 #
21-
20|~ │ 6 # Test both stable and nightly (assuming `nv`
22-
21|~ │ 7 # `make test nvim=nv` or `make test nvim="nvi
14+
13|~ │ doc/fzf-lua-opts.txt │
15+
14|~ ─────────────────────────────────────────────────╯
16+
15|~ ╭─────────────────── Makefile ────────────────────╮
17+
16|~ │ 1 nvim ?= nvim
18+
17|~ │ 2
19+
18|~ │ 3 #
20+
19|~ │ 4 # Run all tests or specic module tests
21+
20|~ │ 5 #
22+
21|~ │ 6 # Test both stable and nightly (assuming `nv`
2323
22|~ ╰─────────────────────────────────────────────────╯
2424
23|~
2525
24|[No Name] 0,0-1 All

0 commit comments

Comments
 (0)