Skip to content

Commit

Permalink
fix: not line for one line fole
Browse files Browse the repository at this point in the history
  • Loading branch information
gh-liu committed Aug 10, 2024
1 parent f525b0e commit cc7b1b8
Show file tree
Hide file tree
Showing 7 changed files with 172 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lua/fold_line/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,16 @@ local function on_win(_, winid, bufnr, toprow, botrow)
return false
end

local one_line_fold = function(i_level, cur_line, cur_line_finfo, prev_line_finfo, next_line_finfo)
if
open_start_sign(i_level, cur_line, cur_line_finfo, prev_line_finfo)
and open_end_sign(i_level, cur_line, cur_line_finfo, next_line_finfo)
then
save_fold_end_line(cur_line, i_level, cur_line_finfo)
return ""
end
end

local row = toprow
while row <= botrow do
local skip_rows
Expand Down Expand Up @@ -375,6 +385,8 @@ local function on_win(_, winid, bufnr, toprow, botrow)
end
end
end
sign = sign
or one_line_fold(i_level, cur_line, cur_line_finfo, prev_line_finfo, next_line_finfo)
sign = sign or open_start_sign(i_level, cur_line, cur_line_finfo, prev_line_finfo)
sign = sign or open_end_sign(i_level, cur_line, cur_line_finfo, next_line_finfo)
sign = sign or fold_signs.f_sep
Expand Down
51 changes: 51 additions & 0 deletions tests/screenshots/tests-test_fold_line.lua---__one_line_fold
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
--|---------|---------|---------|---------|---------|---------|---------|---------|
01| fold
02| fold
03|┌fold
04|│ ┌fold
05|│ │fold
06|│ │fold
07|│ │fold
08|│ │fold
09|│ │fold
10|└ └fold
11|~
12|~
13|~
14|~
15|~
16|~
17|~
18|~
19|~
20|~
21|~
22|~
23|tests/testcases/one_line_fold.txt 1,2 All
24|

--|---------|---------|---------|---------|---------|---------|---------|---------|
01|00000000000000000000000000000000000000000000000000000000000000000000000000000000
02|00000000000000000000000000000000000000000000000000000000000000000000000000000000
03|10000000000000000000000000000000000000000000000000000000000000000000000000000000
04|10000000100000000000000000000000000000000000000000000000000000000000000000000000
05|10000000100000000000000000000000000000000000000000000000000000000000000000000000
06|10000000100000000000000000000000000000000000000000000000000000000000000000000000
07|10000000100000000000000000000000000000000000000000000000000000000000000000000000
08|10000000100000000000000000000000000000000000000000000000000000000000000000000000
09|10000000100000000000000000000000000000000000000000000000000000000000000000000000
10|10000000100000000000000000000000000000000000000000000000000000000000000000000000
11|22222222222222222222222222222222222222222222222222222222222222222222222222222222
12|22222222222222222222222222222222222222222222222222222222222222222222222222222222
13|22222222222222222222222222222222222222222222222222222222222222222222222222222222
14|22222222222222222222222222222222222222222222222222222222222222222222222222222222
15|22222222222222222222222222222222222222222222222222222222222222222222222222222222
16|22222222222222222222222222222222222222222222222222222222222222222222222222222222
17|22222222222222222222222222222222222222222222222222222222222222222222222222222222
18|22222222222222222222222222222222222222222222222222222222222222222222222222222222
19|22222222222222222222222222222222222222222222222222222222222222222222222222222222
20|22222222222222222222222222222222222222222222222222222222222222222222222222222222
21|22222222222222222222222222222222222222222222222222222222222222222222222222222222
22|22222222222222222222222222222222222222222222222222222222222222222222222222222222
23|33333333333333333333333333333333333333333333333333333333333333333333333333333333
24|00000000000000000000000000000000000000000000000000000000000000000000000000000000
51 changes: 51 additions & 0 deletions tests/screenshots/tests-test_fold_line.lua---__one_line_fold2
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
--|---------|---------|---------|---------|---------|---------|---------|---------|
01|┌fold
02|│fold
03|│fold
04|│ fold
05|│ ┌fold
06|│ │fold
07|│ │fold
08|│ │fold
09|│ │fold
10|└ └fold
11|~
12|~
13|~
14|~
15|~
16|~
17|~
18|~
19|~
20|~
21|~
22|~
23|tests/testcases/one_line_fold2.txt 4,2 All
24|

--|---------|---------|---------|---------|---------|---------|---------|---------|
01|01111111111111111111111111111111111111111111111111111111111111111111111111111111
02|01111111111111111111111111111111111111111111111111111111111111111111111111111111
03|01111111111111111111111111111111111111111111111111111111111111111111111111111111
04|01111111111111111111111111111111111111111111111111111111111111111111111111111111
05|01111111011111111111111111111111111111111111111111111111111111111111111111111111
06|01111111011111111111111111111111111111111111111111111111111111111111111111111111
07|01111111011111111111111111111111111111111111111111111111111111111111111111111111
08|01111111011111111111111111111111111111111111111111111111111111111111111111111111
09|01111111011111111111111111111111111111111111111111111111111111111111111111111111
10|01111111011111111111111111111111111111111111111111111111111111111111111111111111
11|22222222222222222222222222222222222222222222222222222222222222222222222222222222
12|22222222222222222222222222222222222222222222222222222222222222222222222222222222
13|22222222222222222222222222222222222222222222222222222222222222222222222222222222
14|22222222222222222222222222222222222222222222222222222222222222222222222222222222
15|22222222222222222222222222222222222222222222222222222222222222222222222222222222
16|22222222222222222222222222222222222222222222222222222222222222222222222222222222
17|22222222222222222222222222222222222222222222222222222222222222222222222222222222
18|22222222222222222222222222222222222222222222222222222222222222222222222222222222
19|22222222222222222222222222222222222222222222222222222222222222222222222222222222
20|22222222222222222222222222222222222222222222222222222222222222222222222222222222
21|22222222222222222222222222222222222222222222222222222222222222222222222222222222
22|22222222222222222222222222222222222222222222222222222222222222222222222222222222
23|33333333333333333333333333333333333333333333333333333333333333333333333333333333
24|11111111111111111111111111111111111111111111111111111111111111111111111111111111
10 changes: 10 additions & 0 deletions tests/testcases/one_line_fold.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
fold
fold
fold
fold
fold
fold
fold
fold
fold
fold
20 changes: 20 additions & 0 deletions tests/testcases/one_line_fold.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
setlocal fdm=manual
setlocal fde=0
setlocal fmr={{{,}}}
setlocal fdi=#
setlocal fdl=99
setlocal fml=1
setlocal fdn=20
setlocal fen
silent! normal! zE
1,1fold
4,10fold
3,10fold
let &fdl = &fdl
1
normal! zc
3
normal! zo

keepjumps 1
" vim: set ft=vim :
10 changes: 10 additions & 0 deletions tests/testcases/one_line_fold2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
fold
fold
fold
fold
fold
fold
fold
fold
fold
fold
18 changes: 18 additions & 0 deletions tests/testcases/one_line_fold2.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
setlocal fdm=manual
setlocal fde=0
setlocal fmr={{{,}}}
setlocal fdi=#
setlocal fdl=99
setlocal fml=1
setlocal fdn=20
setlocal fen
silent! normal! zE
4,4fold
5,10fold
1,10fold
let &fdl = &fdl
1
normal! zo
4
normal! zc
" vim: set ft=vim :

0 comments on commit cc7b1b8

Please sign in to comment.