airblade / vim-gitgutter

A Vim plugin which shows git diff markers in the sign column and stages/previews/undoes hunks and partial hunks.
MIT License
8.37k stars 297 forks source link

GitGutterUndoHunk: after that I see the same ~ but jumped after the next line #850

Closed vitaly-zdanevich closed 1 year ago

vitaly-zdanevich commented 1 year ago

Before:

  >--->---TrItemsParams: TrItemsParams{$
  >--->--->---TrItemParams{$
  >--->--->--->---TransferID:           "at_1",$
  >--->--->--->---Barcode:              "5057107950450",$
  >--->--->--->---AllocatedQuantity:    10,$
  >--->--->--->---PickExceptedQuantity: 0,$
  >--->--->--->---ShippedQuantity:      10,$                                                                                                                               
  >--->--->--->---ReceivedQuantity:     0,$
~ >--->--->--->---Status:               models.ShipmentEventTypeCOMPLETE,$
  >--->--->---},$
  >--->--->---TrItemParams{$
  >--->--->--->---TransferID:           "at_1",$
  >--->--->--->---Barcode:              "5057110120932",$
  >--->--->--->---AllocatedQuantity:    8,$
  >--->--->--->---PickExceptedQuantity: 0,$
  >--->--->--->---ShippedQuantity:      5,$

After:

  >--->---TrItemsParams: TrItemsParams{$
  >--->--->---TrItemParams{$
  >--->--->--->---TransferID:           "at_1",$
  >--->--->--->---Barcode:              "5057107950450",$
  >--->--->--->---AllocatedQuantity:    10,$
  >--->--->--->---PickExceptedQuantity: 0,$
  >--->--->--->---ShippedQuantity:      10,$
  >--->--->--->---ReceivedQuantity:     0,$
  >--->--->--->---Status:               models.ShipmentEventTypeSHIPPED,$
  >--->--->---},$                                                                                                                                                          
~ >--->--->---TrItemParams{$
  >--->--->--->---TransferID:           "at_1",$
  >--->--->--->---Barcode:              "5057110120932",$
  >--->--->--->---AllocatedQuantity:    8,$
  >--->--->--->---PickExceptedQuantity: 0,$
  >--->--->--->---ShippedQuantity:      5,$

~ disappear after I move my mouse to another display and return back.

What is the latest commit SHA in your installed vim-gitgutter?

00df1089b6267f47c7c0f13536789feb9db1e65b


:version
VIM - Vi IMproved 9.0 (2022 Jun 28, compiled Jan 26 2023 14:06:02)
Included patches: 1-1000
Modified by Gentoo-9.0.1000
Compiled by portage@localhost
Huge version without GUI.  Features included (+) or not (-):
+acl               +cmdline_hist      +ex_extra          +jumplist          +mouse_dec         -perl              +sodium            +textobjects       +wildmenu
+arabic            +cmdline_info      +extra_search      +keymap            -mouse_gpm         +persistent_undo   -sound             +textprop          +windows
+autocmd           +comments          -farsi             +lambda            -mouse_jsbterm     +popupwin          +spell             +timers            +writebackup
+autochdir         +conceal           +file_in_path      +langmap           +mouse_netterm     +postscript        +startuptime       +title             +X11
-autoservername    +cryptv            +find_in_path      +libcall           +mouse_sgr         +printer           +statusline        -toolbar           +xfontset
-balloon_eval      -cscope            +float             +linebreak         -mouse_sysmouse    +profile           -sun_workshop      +user_commands     -xim
+balloon_eval_term +cursorbind        +folding           +lispindent        +mouse_urxvt       -python            +syntax            +vartabs           -xpm
-browse            +cursorshape       -footer            +listcmds          +mouse_xterm       -python3           +tag_binary        +vertsplit         +xsmp_interact
++builtin_terms    +dialog_con        +fork()            +localmap          +multi_byte        +quickfix          -tag_old_static    +vim9script        +xterm_clipboard
+byte_offset       +diff              +gettext           -lua               +multi_lang        +reltime           -tag_any_white     +viminfo           -xterm_save
+channel           +digraphs          -hangul_input      +menu              -mzscheme          +rightleft         -tcl               +virtualedit
+cindent           -dnd               +iconv             +mksession         +netbeans_intg     -ruby              +termguicolors     +visual
+clientserver      -ebcdic            +insert_expand     +modify_fname      +num64             +scrollbind        -terminal          +visualextra
+clipboard         +emacs_tags        +ipv6              +mouse             +packages          +signs             +terminfo          +vreplace
+cmdline_compl     +eval              +job               -mouseshape        +path_extra        +smartindent       +termresponse      +wildignore
   system vimrc file: "/etc/vim/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: x86_64-pc-linux-gnu-gcc -c -I. -Iproto -DHAVE_CONFIG_H -O2 -march=native -pipe -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: x86_64-pc-linux-gnu-gcc -Wl,-O1 -Wl,--as-needed -L/usr/local/lib -o vim -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE -lm -ltinfo -lelf -lsodium -lacl -lattr
airblade commented 1 year ago

Are you saying that after GitGutterUndoHunk:

vitaly-zdanevich commented 1 year ago

Are you saying that after GitGutterUndoHunk:

Yes.

but doesn't change the buffer?

No changes to the buffer, but I want to remove ~ after GitGutterUndoHunk :(

This is something on my side?

airblade commented 1 year ago

I suspect you have a default updatetime, or it has a value of a few thousand (milliseconds) or more.

GitGutterUndoHunk updates the buffer's contents as appropriate but doesn't do anything with the signs. The signs are refreshed when gitgutter's CursorHold autocommand next fires.

My updatetime is 100 which is why I never noticed this before.

It makes sense for updating the signs to be part of the hunk commands so I'll update the code to do that.

airblade commented 1 year ago

The code was already updating the signs are staging a hunk; it looks like I simply forgot to do that after undoing a hunk.

Thanks for letting me know about this.

vitaly-zdanevich commented 1 year ago

Thanks, this problem is solved!

But another one:

  1. GitGutterUndoHunk
  2. Undo (it add my changes back)
  3. :w
  4. No ~ added :(, again only after mouse to another window and back.
airblade commented 1 year ago

I can't reproduce that.

What does :verbose set updatetime produce?

vitaly-zdanevich commented 1 year ago

4000

vitaly-zdanevich commented 1 year ago

Oh, yes, ~ is added back after 4 seconds...

airblade commented 1 year ago

So the ~ will vanish after 4 seconds.

I recommend setting updatetime to something much lower, e.g. 100.

airblade commented 1 year ago

Please see the first paragraph of Getting started in the readme :)

vitaly-zdanevich commented 1 year ago

Oh, I see, 4000 is the default number in Vim...

airblade commented 1 year ago

GitGutter doesn't pay any attention to if / when you save a file. It's triggered by CursorHold(I) (and when you change to a different buffer or focus the window etc).