diff --git a/lua/fold_line/init.lua b/lua/fold_line/init.lua index 0e4dd72..184eebb 100644 --- a/lua/fold_line/init.lua +++ b/lua/fold_line/init.lua @@ -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 @@ -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 diff --git a/tests/screenshots/tests-test_fold_line.lua---__one_line_fold b/tests/screenshots/tests-test_fold_line.lua---__one_line_fold new file mode 100644 index 0000000..486b7e6 --- /dev/null +++ b/tests/screenshots/tests-test_fold_line.lua---__one_line_fold @@ -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 diff --git a/tests/screenshots/tests-test_fold_line.lua---__one_line_fold2 b/tests/screenshots/tests-test_fold_line.lua---__one_line_fold2 new file mode 100644 index 0000000..066814a --- /dev/null +++ b/tests/screenshots/tests-test_fold_line.lua---__one_line_fold2 @@ -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 diff --git a/tests/testcases/one_line_fold.txt b/tests/testcases/one_line_fold.txt new file mode 100644 index 0000000..f693440 --- /dev/null +++ b/tests/testcases/one_line_fold.txt @@ -0,0 +1,10 @@ + fold + fold + fold + fold + fold + fold + fold + fold + fold + fold diff --git a/tests/testcases/one_line_fold.vim b/tests/testcases/one_line_fold.vim new file mode 100644 index 0000000..e659ff1 --- /dev/null +++ b/tests/testcases/one_line_fold.vim @@ -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 : diff --git a/tests/testcases/one_line_fold2.txt b/tests/testcases/one_line_fold2.txt new file mode 100644 index 0000000..f693440 --- /dev/null +++ b/tests/testcases/one_line_fold2.txt @@ -0,0 +1,10 @@ + fold + fold + fold + fold + fold + fold + fold + fold + fold + fold diff --git a/tests/testcases/one_line_fold2.vim b/tests/testcases/one_line_fold2.vim new file mode 100644 index 0000000..3aca3c7 --- /dev/null +++ b/tests/testcases/one_line_fold2.vim @@ -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 :