File tree Expand file tree Collapse file tree 1 file changed +15
-10
lines changed
Expand file tree Collapse file tree 1 file changed +15
-10
lines changed Original file line number Diff line number Diff line change @@ -10,16 +10,7 @@ export def Echowarn(msg: string)
1010 echohl WarningMsg | echom $ ' [markdown_extras] {msg}' | echohl None
1111enddef
1212
13- export def FormatWithoutMoving (a: number = 0 , b: number = 0 )
14- # To be used for formatting through autocmds
15- var view = winsaveview ()
16- if a == 0 && b == 0
17- silent exe $ " :norm! gggqG"
18- else
19- var interval = b - a + 1
20- silent exe $ " :norm! {a}gg{interval}gqq"
21- endif
22-
13+ def UndoFormatting ()
2314 if v: shell_error != 0
2415 undo
2516 Echoerr ($ " '{&l:formatprg->matchstr('^\s *\S *')}' returned errors." )
@@ -32,6 +23,20 @@ export def FormatWithoutMoving(a: number = 0, b: number = 0)
3223 Echowarn (" 'formatprg' is empty. Using default formatter." )
3324 endif
3425 endif
26+ enddef
27+
28+ export def FormatWithoutMoving (a: number = 0 , b: number = 0 )
29+ # To be used for formatting through autocmds
30+ var view = winsaveview ()
31+
32+ defer UndoFormatting ()
33+ if a == 0 && b == 0
34+ silent exe $ " :norm! gggqG"
35+ else
36+ var interval = b - a + 1
37+ silent exe $ " :norm! {a}gg{interval}gqq"
38+ endif
39+
3540 winrestview (view )
3641enddef
3742
You can’t perform that action at this time.
0 commit comments