undotree icon indicating copy to clipboard operation
undotree copied to clipboard

[bug] undotree become empty

Open Freed-Wu opened this issue 4 years ago • 7 comments

" $ uname -r
" 5.13.13-arch1-1
" $ has nvim
" ✓ nvim 0.5.0
" $ cat test.vim
set runtimepath=$VIMRUNTIME
set runtimepath+=~/.local/share/nvim/repos/github.com/mbbill/undotree
set undofile
autocmd VimEnter * UndotreeShow
" $ vi -u test.vim one_file_has_undo_histories.

Screenshot from 2021-08-31 13-24-05

Press <C-w>o Screenshot from 2021-08-31 13-24-10

Press :UndotreeShow<CR> Screenshot from 2021-08-31 13-24-16

The undotree is empty!

Freed-Wu avatar Aug 31 '21 05:08 Freed-Wu

the tree should show up once you move the focus to the right side

mbbill avatar Sep 01 '21 02:09 mbbill

the tree should show up once you move the focus to the right side

Thanks.

When I UndotreeShow firstly, the cursor is in the current buffer and the undotree display. However, when I UndotreeShow secondly, the cursor moves to the undotree buffer? This is why?

Freed-Wu avatar Sep 01 '21 03:09 Freed-Wu

I'm not exactly sure, but I guess it might be related to how VIM handles the 'previous window'.

mbbill avatar Sep 07 '21 06:09 mbbill

So it is a bug of (n)vim? 😄

Freed-Wu avatar Sep 11 '21 01:09 Freed-Wu

Also, experiencing this bug.

Closing undotree window with q shows no bug. However closing undotree with :q or ZQ shows this behavior.

RayZ0rr avatar Jan 28 '22 18:01 RayZ0rr

So it is a bug of (n)vim? 😄

@Freed-Wu: I can replicate it in vim 8.1

@RayZ0rr: Good catch!

EtiamNullam avatar Apr 29 '22 00:04 EtiamNullam

I made this hack in lua for neovim as a workaround:

local function enter_undotree()
    vim.api.nvim_command('UndotreeShow')

    local is_glitched = vim.fn.getreg('%') == 'undotree_2'

    if is_glitched then
        vim.api.nvim_command [[
            wincmd w
            wincmd w
            wincmd p
        ]]
    else
        vim.api.nvim_command('UndotreeFocus')
    end
end

EtiamNullam avatar Apr 29 '22 12:04 EtiamNullam