mirror of
https://github.com/neovim/neovim.git
synced 2024-12-19 10:45:16 -07:00
Compare commits
5 Commits
321698ba0a
...
585c57c790
Author | SHA1 | Date | |
---|---|---|---|
|
585c57c790 | ||
|
738320188f | ||
|
38f554e9c4 | ||
|
f7c42433c5 | ||
|
66c429fbf2 |
@ -101,7 +101,8 @@ The result of foldexpr then determines the fold level as follows:
|
||||
"<1", "<2", .. a fold with this level ends at this line
|
||||
">1", ">2", .. a fold with this level starts at this line
|
||||
|
||||
The result values "=", "s" and "a" are more expensive, please see |fold-expr-slow|.
|
||||
The result values "=", "s" and "a" are more expensive, please see
|
||||
|fold-expr-slow|.
|
||||
|
||||
It is not required to mark the start (end) of a fold with ">1" ("<1"), a fold
|
||||
will also start (end) when the fold level is higher (lower) than the fold
|
||||
@ -117,7 +118,7 @@ For debugging the 'debug' option can be set to "msg", the error messages will
|
||||
be visible then.
|
||||
|
||||
If the 'foldexpr' expression starts with s: or |<SID>|, then it is replaced
|
||||
with the script ID (|local-function|). Examples: >
|
||||
with the script ID (|local-function|). Examples: >
|
||||
set foldexpr=s:MyFoldExpr()
|
||||
set foldexpr=<SID>SomeFoldExpr()
|
||||
<
|
||||
@ -141,7 +142,7 @@ end in that line.
|
||||
It may happen that folds are not updated properly. You can use |zx| or |zX|
|
||||
to force updating folds.
|
||||
|
||||
Minimizing Computational Cost *fold-expr-slow*
|
||||
MINIMIZING COMPUTATIONAL COST *fold-expr-slow*
|
||||
|
||||
Due to its computational cost, this fold method can make Vim unresponsive,
|
||||
especially when the fold level of all lines have to be initially computed.
|
||||
@ -149,13 +150,15 @@ Afterwards, after each change, Vim restricts the computation of foldlevels
|
||||
to those lines whose fold level was affected by it (and reuses the known
|
||||
foldlevels of all the others).
|
||||
|
||||
The fold expression should therefore strive to minimize the number of dependent
|
||||
lines needed for the computation of a given line: For example, try to avoid the
|
||||
"=", "a" and "s" return values, because these will require the evaluation of the
|
||||
fold levels on previous lines until an independent fold level is found.
|
||||
The fold expression should therefore strive to minimize the number of
|
||||
dependent lines needed for the computation of a given line: For example, try
|
||||
to avoid the "=", "a" and "s" return values, because these will require the
|
||||
evaluation of the fold levels on previous lines until an independent fold
|
||||
level is found.
|
||||
|
||||
If this proves difficult, the next best thing could be to cache all fold levels
|
||||
in a buffer-local variable (b:foldlevels) that is only updated on |b:changedtick|:
|
||||
If this proves difficult, the next best thing could be to cache all fold
|
||||
levels in a buffer-local variable (b:foldlevels) that is only updated on
|
||||
|b:changedtick|:
|
||||
>vim
|
||||
func MyFoldFunc()
|
||||
if b:lasttick == b:changedtick
|
||||
@ -406,8 +409,8 @@ zX Undo manually opened and closed folds: re-apply 'foldlevel'.
|
||||
Also forces recomputing folds, like |zx|.
|
||||
|
||||
*zm*
|
||||
zm Fold more: Subtract |v:count1| from 'foldlevel'. If 'foldlevel' was
|
||||
already zero nothing happens.
|
||||
zm Fold more: Subtract |v:count1| from 'foldlevel'. If
|
||||
'foldlevel' was already zero nothing happens.
|
||||
'foldenable' will be set.
|
||||
|
||||
*zM*
|
||||
@ -471,7 +474,7 @@ zk Move upwards to the end of the previous fold. A closed fold
|
||||
|
||||
EXECUTING COMMANDS ON FOLDS ~
|
||||
|
||||
:[range]foldd[oopen] {cmd} *:foldd* *:folddo* *:folddoopen*
|
||||
:[range]foldd[oopen] {cmd} *:foldd* *:folddo* *:folddoopen*
|
||||
Execute {cmd} on all lines that are not in a closed fold.
|
||||
When [range] is given, only these lines are used.
|
||||
Each time {cmd} is executed the cursor is positioned on the
|
||||
@ -559,7 +562,7 @@ When there is room after the text, it is filled with the character specified
|
||||
by 'fillchars'.
|
||||
|
||||
If the 'foldtext' expression starts with s: or |<SID>|, then it is replaced
|
||||
with the script ID (|local-function|). Examples: >
|
||||
with the script ID (|local-function|). Examples: >
|
||||
set foldtext=s:MyFoldText()
|
||||
set foldtext=<SID>SomeFoldText()
|
||||
<
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "nvim/strings.h"
|
||||
#include "nvim/textformat.h"
|
||||
#include "nvim/textobject.h"
|
||||
#include "nvim/ui.h"
|
||||
#include "nvim/undo.h"
|
||||
#include "nvim/vim_defs.h"
|
||||
#include "nvim/window.h"
|
||||
@ -1049,12 +1050,18 @@ void format_lines(linenr_T line_count, bool avoid_fex)
|
||||
State = MODE_INSERT; // for open_line()
|
||||
smd_save = p_smd;
|
||||
p_smd = false;
|
||||
|
||||
insertchar(NUL, INSCHAR_FORMAT
|
||||
+ (do_comments ? INSCHAR_DO_COM : 0)
|
||||
+ (do_comments && do_comments_list ? INSCHAR_COM_LIST : 0)
|
||||
+ (avoid_fex ? INSCHAR_NO_FEX : 0), second_indent);
|
||||
|
||||
State = old_State;
|
||||
p_smd = smd_save;
|
||||
// Cursor shape may have been updated (e.g. by :normal) in insertchar(),
|
||||
// so it needs to be updated here.
|
||||
ui_cursor_shape();
|
||||
|
||||
second_indent = -1;
|
||||
// at end of par.: need to set indent of next par.
|
||||
need_set_indent = is_end_par;
|
||||
|
@ -350,12 +350,6 @@ describe('buffer cursor position is correct in terminal without number column',
|
||||
}, {
|
||||
cols = 70,
|
||||
})
|
||||
screen:set_default_attr_ids({
|
||||
[1] = { foreground = 253, background = 11 },
|
||||
[2] = { reverse = true },
|
||||
[3] = { bold = true },
|
||||
[4] = { background = 11 },
|
||||
})
|
||||
-- Also check for real cursor position, as it is used for stuff like input methods
|
||||
screen._handle_busy_start = function() end
|
||||
screen._handle_busy_stop = function() end
|
||||
@ -667,13 +661,6 @@ describe('buffer cursor position is correct in terminal with number column', fun
|
||||
}, {
|
||||
cols = 70,
|
||||
})
|
||||
screen:set_default_attr_ids({
|
||||
[1] = { foreground = 253, background = 11 },
|
||||
[2] = { reverse = true },
|
||||
[3] = { bold = true },
|
||||
[4] = { background = 11 },
|
||||
[7] = { foreground = 130 },
|
||||
})
|
||||
-- Also check for real cursor position, as it is used for stuff like input methods
|
||||
screen._handle_busy_start = function() end
|
||||
screen._handle_busy_stop = function() end
|
||||
|
@ -94,6 +94,46 @@ describe('ui mode_change event', function()
|
||||
}
|
||||
end)
|
||||
|
||||
-- oldtest: Test_indent_norm_with_gq()
|
||||
it('is restored to Normal mode after "gq" indents using :normal #12309', function()
|
||||
screen:try_resize(60, 6)
|
||||
n.exec([[
|
||||
func Indent()
|
||||
exe "normal! \<Ignore>"
|
||||
return 0
|
||||
endfunc
|
||||
|
||||
setlocal indentexpr=Indent()
|
||||
call setline(1, [repeat('a', 80), repeat('b', 80)])
|
||||
]])
|
||||
|
||||
feed('ggVG')
|
||||
screen:expect {
|
||||
grid = [[
|
||||
{17:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}|
|
||||
{17:aaaaaaaaaaaaaaaaaaaa} |
|
||||
^b{17:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb}|
|
||||
{17:bbbbbbbbbbbbbbbbbbbb} |
|
||||
{1:~ }|
|
||||
{5:-- VISUAL LINE --} |
|
||||
]],
|
||||
mode = 'visual',
|
||||
}
|
||||
|
||||
feed('gq')
|
||||
screen:expect {
|
||||
grid = [[
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|
|
||||
aaaaaaaaaaaaaaaaaaaa |
|
||||
^bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb|
|
||||
bbbbbbbbbbbbbbbbbbbb |
|
||||
{1:~ }|
|
||||
|
|
||||
]],
|
||||
mode = 'normal',
|
||||
}
|
||||
end)
|
||||
|
||||
it('works in insert mode', function()
|
||||
feed('i')
|
||||
screen:expect {
|
||||
|
@ -1,5 +1,8 @@
|
||||
" Test for various indent options
|
||||
|
||||
source shared.vim
|
||||
source check.vim
|
||||
|
||||
func Test_preserveindent()
|
||||
new
|
||||
" Test for autoindent copying indent from the previous line
|
||||
@ -303,4 +306,50 @@ func Test_indent_overflow_count2()
|
||||
close!
|
||||
endfunc
|
||||
|
||||
" Test that mouse shape is restored to Normal mode after using "gq" when
|
||||
" 'indentexpr' executes :normal.
|
||||
func Test_indent_norm_with_gq()
|
||||
CheckFeature mouseshape
|
||||
CheckCanRunGui
|
||||
|
||||
let lines =<< trim END
|
||||
func Indent()
|
||||
exe "normal! \<Ignore>"
|
||||
return 0
|
||||
endfunc
|
||||
|
||||
setlocal indentexpr=Indent()
|
||||
END
|
||||
call writefile(lines, 'Xindentexpr.vim', 'D')
|
||||
|
||||
let lines =<< trim END
|
||||
vim9script
|
||||
var mouse_shapes = []
|
||||
|
||||
setline(1, [repeat('a', 80), repeat('b', 80)])
|
||||
|
||||
feedkeys('ggVG')
|
||||
timer_start(50, (_) => {
|
||||
mouse_shapes += [getmouseshape()]
|
||||
timer_start(50, (_) => {
|
||||
feedkeys('gq')
|
||||
timer_start(50, (_) => {
|
||||
mouse_shapes += [getmouseshape()]
|
||||
timer_start(50, (_) => {
|
||||
writefile(mouse_shapes, 'Xmouseshapes')
|
||||
quit!
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
END
|
||||
call writefile(lines, 'Xmouseshape.vim', 'D')
|
||||
|
||||
call RunVim([], [], "-g -S Xindentexpr.vim -S Xmouseshape.vim")
|
||||
call WaitForAssert({-> assert_equal(['rightup-arrow', 'arrow'],
|
||||
\ readfile('Xmouseshapes'))}, 300)
|
||||
|
||||
call delete('Xmouseshapes')
|
||||
endfunc
|
||||
|
||||
" vim: shiftwidth=2 sts=2 expandtab
|
||||
|
@ -59,7 +59,8 @@ func Test_window_preview_terminal()
|
||||
CheckFeature quickfix
|
||||
" CheckFeature terminal
|
||||
|
||||
term " ++curwin
|
||||
" term ++curwin
|
||||
term
|
||||
const buf_num = bufnr('$')
|
||||
call assert_equal(1, winnr('$'))
|
||||
exe 'pbuffer' . buf_num
|
||||
|
Loading…
Reference in New Issue
Block a user