rust-lang / rust.vim

Vim configuration for Rust.
Apache License 2.0
3.88k stars 295 forks source link

Rustfmt on save causes undo to jump to beginning of file #236

Closed Marwes closed 6 years ago

Marwes commented 6 years ago

Steps to reproduce:

Make a change in a file then save so rustfmt (on save) is run. Then undo the change.

Expected vs. actual behavior:

Undoing the change(s) should make the view stay at where the manual change was made. What happens instead is that the view jumps to the beginning of the file.

Bisected to one of the following commits (formatting was broken in many of them so I don't know which exactly).

a5290d6ec2e8da8474e8eaf3aa3b2847b7f66e97 f1d785a3135d3187f22d79823e0fa995cbcffdbc ba190eecc64a6c7103a569f23fb223f69e49869d ff54b40bbcb2034f98283fbe4bbccc0e9d57f6f4 6b4eb5d9ceb0b2437966adfcb1fd2064403cebc3 c7c99f3d8fcdbda1be03a7ebee109609605f681f aff86a1a11245bf7ad641c40a08b01922b59dc1f

rust.vim Global Variables:

let g:ftplugin_rust_source_path = v:null
let g:loaded_syntastic_rust_cargo_checker = v:null
let g:loaded_syntastic_rust_filetype = v:null
let g:loaded_syntastic_rust_rustc_checker = v:null
let g:rust_bang_comment_leader = v:null
let g:rust_cargo_avoid_whole_workspace = v:null
let g:rust_clip_command = v:null
let g:rust_conceal = v:null
let g:rust_conceal_mod_path = v:null
let g:rust_conceal_pub = v:null
let g:rust_fold = v:null
let g:rust_last_args = v:null
let b:rust_last_args = []
let g:rust_last_rustc_args = v:null
let b:rust_last_rustc_args = []
let g:rust_original_delimitMate_excluded_regions = v:null
let g:rust_playpen_url = v:null
let g:rust_recent_nearest_cargo_tol = v:null
let g:rust_recent_root_cargo_toml = v:null
let g:rust_recommended_style = v:null
let g:rust_set_conceallevel = v:null
let g:rust_set_conceallevel=1 = v:null
let g:rust_set_foldmethod = v:null
let g:rust_set_foldmethod=1 = v:null
let g:rust_shortener_url = v:null
let g:rustc_makeprg_no_percent = v:null
let g:rustc_path = v:null
let g:rustfmt_autosave = 1
let g:rustfmt_autosave_because_of_config = v:null
let g:rustfmt_autosave_if_config_present = v:null
let g:rustfmt_command = 'rustfmt'
let g:rustfmt_emit_files = 0
let g:rustfmt_fail_silently = 0
let g:rustfmt_options = ''
let g:syntastic_extra_filetypes = ['rust']
let g:syntastic_rust_cargo_fname = v:null
rustfmt 0.6.1-stable (49279d71 2018-05-08)

rustc 1.27.0 (3eda71b00 2018-06-19)

cargo 1.27.0 (1e95190e5 2018-05-27)

NVIM v0.2.2
Build type: Release
LuaJIT 2.0.5
Compilation: /usr/local/Homebrew/Library/Homebrew/shims/super/clang -Wconversion -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DNDEBUG -DMIN_LOG_LEVEL=3 -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -I/tmp/neovim-20180209-92407-udkzoo/neovim-0.2.2/build/config -I/tmp/neovim-20180209-92407-udkzoo/neovim-0.2.2/src -I/usr/local/include -I/usr/local/include -I/usr/local/include -I/usr/local/include -I/usr/local/include -I/usr/local/include -I/usr/local/opt/gettext/include -I/usr/include -I/tmp/neovim-20180209-92407-udkzoo/neovim-0.2.2/build/src/nvim/auto -I/tmp/neovim-20180209-92407-udkzoo/neovim-0.2.2/build/include
Kompilerad av brew@HighSierra.local

Features: +acl +iconv +jemalloc +tui 
See ":help feature-compile"

   system-vimrc-fil: "$VIM/sysinit.vim"
  reserv för $VIM: "/usr/local/Cellar/neovim/0.2.2_1/share/nvim"

Run :checkhealth for more info
Marwes commented 6 years ago

Guessing its this change https://github.com/rust-lang/rust.vim/commit/f1d785a3135d3187f22d79823e0fa995cbcffdbc#diff-620e97ff3ec1f7b01a2d1f60373196cdR107 or perhaps the silent edit! that was removed (no idea what that actually does though)?

da-x commented 6 years ago

Applied a fix in master, try it now please?

Marwes commented 6 years ago

It works now! Thanks for the speedy fix!