wfxr / minimap.vim

📡 Blazing fast minimap / scrollbar for vim, powered by code-minimap written in Rust.
MIT License
1.19k stars 24 forks source link

E474 error in minimap_buffer_enter_handler when opening minimap buffer without a file #199

Open kuangyujing opened 3 days ago

kuangyujing commented 3 days ago

Check list

Environment info

Version info

VIM - Vi IMproved 9.1 (2024 Jan 02, compiled Sep 30 2024 17:42:28)
macOS version - arm64
Included patches: 1-750
Compiled by Homebrew
Huge version without GUI.  Features included (+) or not (-):
+acl               +file_in_path      +mouse_urxvt       -tag_any_white
+arabic            +find_in_path      +mouse_xterm       -tcl
+autocmd           +float             +multi_byte        +termguicolors
+autochdir         +folding           +multi_lang        +terminal
-autoservername    -footer            -mzscheme          +terminfo
-balloon_eval      +fork()            +netbeans_intg     +termresponse
+balloon_eval_term +gettext           +num64             +textobjects
-browse            -hangul_input      +packages          +textprop
++builtin_terms    +iconv             +path_extra        +timers
+byte_offset       +insert_expand     +perl              +title
+channel           +ipv6              +persistent_undo   -toolbar
+cindent           +job               +popupwin          +user_commands
-clientserver      +jumplist          +postscript        +vartabs
+clipboard         +keymap            +printer           +vertsplit
+cmdline_compl     +lambda            +profile           +vim9script
+cmdline_hist      +langmap           -python            +viminfo
+cmdline_info      +libcall           +python3           +virtualedit
+comments          +linebreak         +quickfix          +visual
+conceal           +lispindent        +reltime           +visualextra
+cryptv            +listcmds          +rightleft         +vreplace
+cscope            +localmap          +ruby              +wildignore
+cursorbind        +lua               +scrollbind        +wildmenu
+cursorshape       +menu              +signs             +windows
+dialog_con        +mksession         +smartindent       +writebackup
+diff              +modify_fname      +sodium            -X11
+digraphs          +mouse             +sound             -xattr
-dnd               -mouseshape        +spell             -xfontset
-ebcdic            +mouse_dec         +startuptime       -xim
+emacs_tags        -mouse_gpm         +statusline        -xpm
+eval              -mouse_jsbterm     -sun_workshop      -xsmp
+ex_extra          +mouse_netterm     +syntax            -xterm_clipboard
+extra_search      +mouse_sgr         +tag_binary        -xterm_save
-farsi             -mouse_sysmouse    -tag_old_static
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
 3rd user vimrc file: "~/.config/vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/opt/homebrew/share/vim"
Compilation: clang -c -I. -Iproto -DHAVE_CONFIG_H -DMACOS_X -DMACOS_X_DARWIN -g -O2 -I/opt/homebrew/Cellar/libsodium/1.0.20/include -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: clang -o vim -lm -lncurses -L/opt/homebrew/Cellar/libsodium/1.0.20/lib -lsodium -liconv -lintl -framework AppKit -L/opt/homebrew/opt/lua/lib -llua5.4 -fstack-protector-strong -L/System/Library/Perl/5.30/darwin-thread-multi-2level/CORE -lperl -L/opt/homebrew/opt/python@3.12/Frameworks/Python.framework/Versions/3.12/lib/python3.12/config-3.12-darwin -lpython3.12 -framework CoreFoundation -lruby.3.3 -L/opt/homebrew/Cellar/ruby/3.3.5/lib

Question / Problem and steps to reproduce

When I open Vim without specifying any files, switching to the minimap buffer results in the following error:

image

Error detected while processing BufEnter Autocommands for "*"..function <SNR>53_
handle_autocmd[23]..<SNR>53_buffer_enter_handler[2]..<SNR>53_minimap_buffer_ente
r_handler:
line    3:
E474: Invalid argument
Press ENTER or type command to continue

This issue occurs because the minimap buffer attempts to move the cursor to an invalid position. This typically happens when s:last_pos is not set correctly. As a result, the cursor() function is called with an empty or zero value, which causes the error.

To reproduce:

  1. Set g:minimap_auto_start to 1 in your vimrc configuration.
  2. Open Vim without specifying any files.

Expected behavior: Switching to the minimap buffer should not produce any errors, and the cursor should remain in a valid position.

kuangyujing commented 3 days ago

https://github.com/wfxr/minimap.vim/pull/198

I also create fix that addresses this issue. Please review it, and if it resolves the problem, I would appreciate it if you could consider merging it.