emacs-evil/goto-chg

Insertion of tabs shifts prior changes

axelf4 opened this issue · 3 comments

After inserting a bunch of tabs going to the earlier changes puts the point in the wrong spots.

I am using the following packages:

  • evil: at commit emacs-evil/evil@17c635f
  • undo-tree: at commit with Timestamp: 2020-11-28 21:05:29
  • goto-chg: at commit 3ce1389
  • (plus a bunch of miscellaneous packages that hopefully are not to blame.)

To reproduce:

  • Set glc-default-span to 1.

  • Enter a new buffer.

  • Insert foo with ifoo<Esc>

  • Insert \n...\nbar with o<RET><RET><RET>bar<Esc>

  • Goto first line and prepend a bunch of Tab:s with ggI^v<Tab>^v<Tab>^v<Tab>^v<Tab>^v<Tab>^v<Tab>

  • The buffer now looks like

    						foo
    
    
    bar
    
  • Executing M-x goto-last-change now puts the cursor in the expected spot:

    						█oo
    
    
    bar
    

    where denotes the cursor.

  • However, executing M-x goto-last-change again puts it in the wrong place:

    						foo
    █
    
    bar
    

    instead I would have expected it to put the cursor on the r, which is what I get if instead of Tab:s I inserted e.g. spaces.

I cannot reproduce this, neither with my customized Emacs nor by a minimal session (run by executing make emacs from a Git checkout of Evil, then visiting goto-chg.el, evaluating its buffer, then following the repro instructions). I advise you to do the same before opening bug reports.

I apologize for wasting your time. However I am able to reproduce it using make emacs still (asciinema), were you perhaps not enabling undo-tree? The precise steps:

  • Run make emacs in the Evil tree checked out at emacs-evil/evil@215c39d (master is buggy for me?)

  • Source undo-tree.el and goto-chg.el

  • Source

    (setq glc-default-span 1)
    (setq-default tab-width 4)
    (add-hook 'evil-local-mode-hook #'undo-tree-mode)
  • Proceed with the steps outlined in the original issue

You're right, I forgot about undo-tree and generally prefer not using it if possible. If it's enabled, goto-chg uses a different strategy for discovering the last change by using buffer-undo-tree instead of buffer-undo-list. It's best-effort code lifted from https://github.com/martinp26/goto-chg. The code is absolutely inscrutable for me and requires someone actually understanding undo-tree to fix it.