Skip to content

Diff does not refresh when navigating in undo history #192

@creinig

Description

@creinig

When navigating between items in the undo history panel, the contents of the diff panel never change.

❯ nvim -V1 -v                       
NVIM v0.10.4
Build type: Release
LuaJIT 2.1.1736781742

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "
/home/linuxbrew/.linuxbrew/Cellar/neovim/0.10.4/share/nvim"

Plugin setup code:

 { -- easily access & handle undo history                                                                                                                                                                                     
     'mbbill/undotree',                                                                                                                                                                                                         
     init = function()                                                                                                                                                                                                          
       vim.keymap.set("n", "<leader>uu", vim.cmd.UndotreeToggle, { desc = "Toggle [U]ndo history" })                                                                                                                            
       vim.g.undotree_WindowLayout = 2                                                                                                                                                                                          
       vim.g.unditree_ShortIndicators = 1                                                                                                                                                                                       
       vim.g.undotree_DiffpanelHeight = 15                                                                                                                                                                                      
       vim.g.undotree_SetFocusWhenToggle = 1                                                                                                                                                                                    
     end                                                                                                                                                                                                                        
  },      

Annotated ~/undotree_debug.log:

-- > open nvim, navigate to file without persistent undo history
-- > add line at top
-- > add another line at top
-- > execute :UndotreeToggle
  =======================================
  10:50:40: 'undotree#UndotreePersistUndo(0)'
  10:50:40: ' > Undofile has been set. Do nothing.'
  10:51:45: '>>> UndotreeToggle()'
  10:51:45: 'Unique window id assigned: id_1'
  10:51:45: 'undotree_2 Toggle()'
  10:51:45: 'undotree.Show()'
  10:51:45: 's:exec() silent keepalt topleft vertical30 new undotree_2'
  10:51:45: 's:exec() norm! 2^W^W'
  10:51:45: 'undotree.Update() update whole tree'
  10:51:45: 'SetFocus() winnr:1 bufname:undotree_2'
  10:51:45: 's:exec_silent() norm! 1^W^W'
  10:51:45: 's:exec() 1,$ d _'
  10:51:45: 's:exec() $d _'
  10:51:45: 'bak(cur,curhead,newhead): -1 -1 -1'
  10:51:45: '(cur,curhead,newhead): 2 -1 2'
  10:51:45: 's:exec() normal! 3G'
  10:51:45: 'undotree.UpdateDiff()'
  10:51:45: 'diffpanel.Show()'
  10:51:45: 's:exec_silent() botright 15new diffpanel_3'
  10:51:45: 'SetFocus() winnr:1 bufname:undotree_2'
  10:51:45: 's:exec_silent() norm! 1^W^W'
  10:51:45: 'undotree.UpdateDiff()'
  10:51:45: 'diffpanel.Update(),seq:2 bufname:.config/nvim/lua/plugins/init.lua'
  10:51:45: 's:exec_silent() 2 wincmd w'
  10:51:45: 'diffresult: [''1a2'', ''> -- world'']'
  10:51:45: 'matchadd(a) ->  \%2l\V-- world'
  10:51:45: 'SetFocus() winnr:3 bufname:diffpanel_3'
  10:51:45: 's:exec_silent() norm! 3^W^W'
  10:51:45: 's:exec() 1,$ d _'
  10:51:45: 's:exec() $d _'
  10:51:45: 's:exec() norm! gg'
  10:51:45: 'SetFocus() winnr:1 bufname:undotree_2'
  10:51:45: 's:exec_silent() norm! 1^W^W'
  10:51:45: '<<< UndotreeToggle() leave'
  10:51:45: 'Unique window id assigned: id_4'

-- > undotree UI is displayed, shows 2 changed. Diff shows latest change.
-- > navigate between undo items via cursor keys / j/k. No change in the diff panel, no log output

-- > Press "D" to hide diff panel

  10:52:17: 'undotreeAction()'
  10:52:17: 'undotree.Action() DiffToggle'
  10:52:17: 'diffpanel_3 Toggle()'
  10:52:17: 'diffpanel_3 Hide()'
  10:52:17: 'SetFocus() winnr:3 bufname:diffpanel_3'
  10:52:17: 's:exec_silent() norm! 3^W^W'
  10:52:17: 's:exec() quit'
  10:52:17: 'CleanUpHighlight()'
  10:52:17: 's:exec_silent() norm! 1^W^W'
  10:52:17: 's:exec_silent() norm! 2^W^W'
  10:52:17: 's:exec_silent() norm! 1^W^W'
  10:52:17: 'undotree.UpdateDiff()'

-- > press "D" to show diff panel again

  10:52:26: 'undotreeAction()'
  10:52:26: 'undotree.Action() DiffToggle'
  10:52:26: 'diffpanel_3 Toggle()'
  10:52:26: 'diffpanel.Show()'
  10:52:26: 's:exec_silent() botright 15new diffpanel_3'
  10:52:26: 'SetFocus() winnr:1 bufname:undotree_2'
  10:52:26: 's:exec_silent() norm! 1^W^W'
  10:52:26: 'undotree.UpdateDiff()'
  10:52:26: 'diffpanel.Update(),seq:2 bufname:.config/nvim/lua/plugins/init.lua'
  10:52:26: 'diff cache hit.'
  10:52:26: 's:exec() norm! 2^W^W'
  10:52:26: 'undotree.Update() update seqs'
  10:52:26: 'matchadd(a) ->  \%2l\V-- world'
  10:52:26: 'SetFocus() winnr:3 bufname:diffpanel_3'
  10:52:26: 's:exec_silent() norm! 3^W^W'
  10:52:26: 's:exec() 1,$ d _'
  10:52:26: 's:exec() $d _'
  10:52:26: 's:exec() norm! gg'
  10:52:26: 'SetFocus() winnr:1 bufname:undotree_2'
  10:52:26: 's:exec_silent() norm! 1^W^W'

-- > Diff panel is shown, but without any changes. Navigating between items still doesn't do anything there

-- > press "q" to leave undotree

  10:52:45: 'undotreeAction()'
  10:52:45: 'undotree.Action() Close'
  10:52:45: 'undotree_2 Toggle()'
  10:52:45: 'undotree_2 Hide()'
  10:52:45: 's:exec() quit'
  10:52:45: 'diffpanel_3 Hide()'
  10:52:45: 'SetFocus() winnr:3 bufname:diffpanel_3'
  10:52:45: 's:exec_silent() norm! 3^W^W'
  10:52:45: 's:exec() quit'
  10:52:45: 'CleanUpHighlight()'
  10:52:45: 's:exec_silent() norm! 1^W^W'
  10:52:45: 's:exec_silent() norm! 2^W^W'
  10:52:45: 's:exec_silent() norm! 1^W^W'

When re-opening the diff panel, the log shows "diff cache hit." , despite there being no previous "diffresult:" line for that change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions