Skip to content

Commit 96e79e3

Browse files
itchynyda-x
authored andcommitted
Use winsaveview()/winrestview() instead of :mkview/:loadview for restoring the window view
The current implementation fails to restore the cursor position when - it fails to store the view due to incorrectly configured 'viewdir' - 'viewoptions' does not include 'cursor' Using winsaveview()/winrestview() can restore the view with no side-effect.
1 parent 2a67368 commit 96e79e3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

autoload/rustfmt.vim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ function! s:DeleteLines(start, end) abort
107107
endfunction
108108

109109
function! s:RunRustfmt(command, tmpname, from_writepre)
110-
mkview!
110+
let l:view = winsaveview()
111111

112112
let l:stderr_tmpname = tempname()
113113
call writefile([], l:stderr_tmpname)
@@ -213,7 +213,7 @@ function! s:RunRustfmt(command, tmpname, from_writepre)
213213
lwindow
214214
endif
215215

216-
silent! loadview
216+
call winrestview(l:view)
217217
endfunction
218218

219219
function! rustfmt#FormatRange(line1, line2)

0 commit comments

Comments
 (0)