We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ca1d712 commit 8384920Copy full SHA for 8384920
autoload/go/fmt.vim
@@ -70,6 +70,8 @@ function! go#fmt#Format(withGoimport) abort
70
endif
71
72
let out = go#fmt#run(bin_name, l:tmpname, expand('%'))
73
+ let diff_offset = len(readfile(l:tmpname)) - line('$')
74
+
75
if go#util#ShellError() == 0
76
call go#fmt#update_file(l:tmpname, expand('%'))
77
elseif g:go_fmt_fail_silently == 0
@@ -95,6 +97,9 @@ function! go#fmt#Format(withGoimport) abort
95
97
" Restore our cursor/windows positions.
96
98
call winrestview(l:curw)
99
100
101
+ " be smart and jump to the line the new statement was added/removed
102
+ call cursor(line('.') + diff_offset, 0)
103
endfunction
104
105
" update_file updates the target file with the given formatted source
0 commit comments