Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different behaviour from another submitter (auto-indent while typing in insert mode) #390

Open
glibg10b opened this issue Oct 20, 2024 · 5 comments

Comments

@glibg10b
Copy link

Submission 1414 of challenge 4d1a1c36567bac34a9000002 contains the following:

faDlaa.join(',')}"<Esc>k

This operates on line 3 of the following half-completed file:

class Golfer
  def self.hello(a,b,c,d)
    puts "Hello #{a}, #{b}, #{c}, #{d}" # this line
  end
end

When I get to the . keystroke in insert mode, the whole line's indentation increases by a lot. This is not taken into account by that submission, so it must only be happening to me.

I can reproduce it outside of VimGolf with VimGolf's .vimrc (/bin/vim -u <vim-golf's .vimrc>), but only if I set ft=ruby first.

Does someone know a way I could find what's causing this?

vimlog
sourcing "vim-golf.vimrc"
chdir(/usr/share/vim/vim91/syntax)
fchdir() to previous dir
line 24: sourcing "/usr/share/vim/vim91/syntax/syntax.vim"
chdir(/usr/share/vim/vim91/syntax)
fchdir() to previous dir
line 20: sourcing "/usr/share/vim/vim91/syntax/synload.vim"
chdir(/usr/share/vim/vim91/syntax)
fchdir() to previous dir
line 22: sourcing "/usr/share/vim/vim91/syntax/syncolor.vim"
chdir(/usr/share/vim/vim91/colors/lists)
fchdir() to previous dir
line 57: sourcing "/usr/share/vim/vim91/colors/lists/default.vim"
finished sourcing /usr/share/vim/vim91/colors/lists/default.vim
continuing in /usr/share/vim/vim91/syntax/syncolor.vim
finished sourcing /usr/share/vim/vim91/syntax/syncolor.vim
continuing in /usr/share/vim/vim91/syntax/synload.vim
finished sourcing /usr/share/vim/vim91/syntax/synload.vim
continuing in /usr/share/vim/vim91/syntax/syntax.vim
chdir(/usr/share/vim/vim91)
fchdir() to previous dir
line 26: sourcing "/usr/share/vim/vim91/filetype.vim"
not found in 'runtimepath': "ftdetect/*.vim"
finished sourcing /usr/share/vim/vim91/filetype.vim
continuing in /usr/share/vim/vim91/syntax/syntax.vim
Executing FileType Autocommands for "*"
autocommand 0verbose exe "set syntax=" . expand("<amatch>")

Executing BufRead Autocommands for "*"
autocommand if !did_filetype() && expand("<amatch>") !~ g:ft_ignore_pat | runtime! scripts.vim | endif

chdir(/usr/share/vim/vim91)
fchdir() to previous dir
line 0: sourcing "/usr/share/vim/vim91/scripts.vim"
chdir(/usr/share/vim/vim91/autoload/dist)
fchdir() to previous dir
line 27: sourcing "/usr/share/vim/vim91/autoload/dist/script.vim"
finished sourcing /usr/share/vim/vim91/autoload/dist/script.vim
continuing in /usr/share/vim/vim91/scripts.vim
finished sourcing /usr/share/vim/vim91/scripts.vim
continuing in BufRead Autocommands for "*"
Executing BufRead Autocommands for "*"
autocommand if !did_filetype() && expand("<amatch>") !~ g:ft_ignore_pat    && (expand("<amatch>") =~# '\.conf$'^I|| getline(1) =~ '^#' || getline(2) =~ '^#'^I|| getline(3) =~ '^#' || getline(4) =~ '^#'^I|| getline(5) =~ '^#') |   setf FALLBACK conf | endif

finished sourcing /usr/share/vim/vim91/syntax/syntax.vim
continuing in /home/waldo/Downloads/vim-golf.vimrc
chdir(/usr/share/vim/vim91)
fchdir() to previous dir
line 25: sourcing "/usr/share/vim/vim91/filetype.vim"
finished sourcing /usr/share/vim/vim91/filetype.vim
continuing in /home/waldo/Downloads/vim-golf.vimrc
chdir(/usr/share/vim/vim91)
fchdir() to previous dir
line 26: sourcing "/usr/share/vim/vim91/filetype.vim"
finished sourcing /usr/share/vim/vim91/filetype.vim
continuing in /home/waldo/Downloads/vim-golf.vimrc
chdir(/usr/share/vim/vim91)
fchdir() to previous dir
line 26: sourcing "/usr/share/vim/vim91/indent.vim"
finished sourcing /usr/share/vim/vim91/indent.vim
continuing in /home/waldo/Downloads/vim-golf.vimrc
finished sourcing vim-golf.vimrc
not found in 'packpath': "pack/*/start/*"
chdir(/usr/share/vim/vim91/plugin)
fchdir() to previous dir
sourcing "/usr/share/vim/vim91/plugin/getscriptPlugin.vim"
finished sourcing /usr/share/vim/vim91/plugin/getscriptPlugin.vim
chdir(/usr/share/vim/vim91/plugin)
fchdir() to previous dir
sourcing "/usr/share/vim/vim91/plugin/gzip.vim"
finished sourcing /usr/share/vim/vim91/plugin/gzip.vim
chdir(/usr/share/vim/vim91/plugin)
fchdir() to previous dir
sourcing "/usr/share/vim/vim91/plugin/logiPat.vim"
finished sourcing /usr/share/vim/vim91/plugin/logiPat.vim
chdir(/usr/share/vim/vim91/plugin)
fchdir() to previous dir
sourcing "/usr/share/vim/vim91/plugin/manpager.vim"
finished sourcing /usr/share/vim/vim91/plugin/manpager.vim
chdir(/usr/share/vim/vim91/plugin)
fchdir() to previous dir
sourcing "/usr/share/vim/vim91/plugin/matchparen.vim"
finished sourcing /usr/share/vim/vim91/plugin/matchparen.vim
chdir(/usr/share/vim/vim91/plugin)
fchdir() to previous dir
sourcing "/usr/share/vim/vim91/plugin/netrwPlugin.vim"
finished sourcing /usr/share/vim/vim91/plugin/netrwPlugin.vim
chdir(/usr/share/vim/vim91/plugin)
fchdir() to previous dir
sourcing "/usr/share/vim/vim91/plugin/rrhelper.vim"
finished sourcing /usr/share/vim/vim91/plugin/rrhelper.vim
chdir(/usr/share/vim/vim91/plugin)
fchdir() to previous dir
sourcing "/usr/share/vim/vim91/plugin/spellfile.vim"
finished sourcing /usr/share/vim/vim91/plugin/spellfile.vim
chdir(/usr/share/vim/vim91/plugin)
fchdir() to previous dir
sourcing "/usr/share/vim/vim91/plugin/tarPlugin.vim"
finished sourcing /usr/share/vim/vim91/plugin/tarPlugin.vim
chdir(/usr/share/vim/vim91/plugin)
fchdir() to previous dir
sourcing "/usr/share/vim/vim91/plugin/tohtml.vim"
finished sourcing /usr/share/vim/vim91/plugin/tohtml.vim
chdir(/usr/share/vim/vim91/plugin)
fchdir() to previous dir
sourcing "/usr/share/vim/vim91/plugin/vimballPlugin.vim"
finished sourcing /usr/share/vim/vim91/plugin/vimballPlugin.vim
chdir(/usr/share/vim/vim91/plugin)
fchdir() to previous dir
sourcing "/usr/share/vim/vim91/plugin/zipPlugin.vim"
finished sourcing /usr/share/vim/vim91/plugin/zipPlugin.vim
not found in 'packpath': "pack/*/start/*"
not found in 'runtimepath': "plugin/**/*.vim"
Reading viminfo file "/home/waldo/.viminfo" info oldfiles
Executing BufWinEnter Autocommands for "*"
autocommand autocmd SafeState * ++once call s:Highlight_Matching_Pair()

Executing BufEnter Autocommands for "*"
autocommand sil call s:LocalBrowse(expand("<amatch>"))

Executing VimEnter Autocommands for "*"
autocommand sil call s:VimEnter(expand("<amatch>"))

Executing CursorMoved Autocommands for "*"
autocommand call s:Highlight_Matching_Pair()

Executing SafeState Autocommands for "*"
autocommand call s:Highlight_Matching_Pair()
-- INSERT --

Executing CursorMoved Autocommands for "*"
autocommand call s:Highlight_Matching_Pair()

Executing TextChanged Autocommands for "*"
autocommand call s:Highlight_Matching_Pair()

Executing CursorMoved Autocommands for "*"
autocommand call s:Highlight_Matching_Pair()

Executing CursorMoved Autocommands for "*"
autocommand call s:Highlight_Matching_Pair()


Executing FileType Autocommands for "*"
autocommand 0verbose exe "set syntax=" . expand("<amatch>")

Executing FileType Autocommands for "*"
autocommand call s:LoadIndent()

chdir(/usr/share/vim/vim91/indent)
fchdir() to previous dir
line 14: sourcing "/usr/share/vim/vim91/indent/ruby.vim"
finished sourcing /usr/share/vim/vim91/indent/ruby.vim
continuing in <SNR>9_LoadIndent
Executing CursorMoved Autocommands for "*"
autocommand call s:Highlight_Matching_Pair()

Executing TextChanged Autocommands for "*"
autocommand call s:Highlight_Matching_Pair()

Executing CursorMoved Autocommands for "*"
autocommand call s:Highlight_Matching_Pair()

Executing CursorMoved Autocommands for "*"
autocommand call s:Highlight_Matching_Pair()
-- INSERT --
Executing CursorMovedI Autocommands for "*"
autocommand call s:Highlight_Matching_Pair()

Executing TextChangedI Autocommands for "*"
autocommand call s:Highlight_Matching_Pair()

Executing CursorMovedI Autocommands for "*"
autocommand call s:Highlight_Matching_Pair()

Executing TextChangedI Autocommands for "*"
autocommand call s:Highlight_Matching_Pair()


Executing CursorMoved Autocommands for "*"
autocommand call s:Highlight_Matching_Pair()

Writing viminfo file "/home/waldo/.viminfo"
vim --version -u Downloads/vim-golf.vimrc
VIM - Vi IMproved 9.1 (2024 Jan 02, compiled Oct 20 2024 05:53:49)
Included patches: 1-366
Modified by Gentoo-9.1.0366 (RIP Bram)
Compiled by waldo@localhost
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: "/etc/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: "/usr/share/vim"
Compilation: x86_64-pc-linux-gnu-gcc -c -I. -Iproto -DHAVE_CONFIG_H -Ofast -flto=auto -pipe -march=alderlake -mabm -mno-cldemote -mno-kl -mno-pconfig -mno-sgx -mno-widekl -mshstk --param=l1-cache-line-size=64 --param=l1-cache-size=32 --param=l2-cache-size=12288 -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 
Linking: x86_64-pc-linux-gnu-gcc -Wl,-O1 -Wl,--as-needed -Wl,-z,pack-relative-relocs -Ofast -flto=auto -pipe -march=alderlake -mabm -mno-cldemote -mno-kl -mno-pconfig -mno-sgx -mno-widekl -mshstk --param=l1-cache-line-size=64 --param=l1-cache-size=32 --param=l2-cache-size=12288 -Wl,-O3 -Wl,--as-needed -L/usr/local/lib -o vim -lm -ltinfo -lelf -lcanberra -lsodium -lacl -lattr 
@maiku1008
Copy link

I also encounter this in the same exercise

@sedm0784
Copy link

The indentation occurs because you have . in your 'indentkeys' option, and 'indentexpr' most likely set to GetRubyIndent(v:lnum).

Both of these are set by the standard ruby filetype, so it looks like this is being set for you and not for the author of that submission.

I don't know off the top of my head how the filetype is being set for you (and don't have vimgolf installed right now to check). What's the output of :verbose set ft? when run from inside a vimgolf instance with that challenge loaded?

@glibg10b
Copy link
Author

Here's the output for :verbose set ft?:

  filetype=ruby
        Last set from /usr/share/vim/vim91/filetype.vim line 2008

That file starts as follows:

" Vim support file to detect file types
"
" Maintainer:	The Vim Project <https://github.com/vim/vim>
" Last Change:	2023 Dec 06
" Former Maintainer:	Bram Moolenaar <[email protected]>

Here are the lines around line 2008:

  2001	" RTF
  2002	au BufNewFile,BufRead *.rtf			setf rtf
  2003	
  2004	" Interactive Ruby shell
  2005	au BufNewFile,BufRead .irbrc,irbrc,.irb_history,irb_history	setf ruby
  2006	
  2007	" Ruby
  2008	au BufNewFile,BufRead *.rb,*.rbw		setf ruby
  2009	
  2010	" RubyGems
  2011	au BufNewFile,BufRead *.gemspec			setf ruby
  2012	
  2013	" RBS (Ruby Signature)
  2014	au BufNewFile,BufRead *.rbs			setf rbs

@karamfil
Copy link

karamfil commented Nov 27, 2024

I am experiencing the same problem using the docker container, when I press . it indents weirdly.

After some digging, I believe I found out what is causing this.

. is part of indentkeys in /usr/share/vim/vim82/indent/ruby.vim:37

setlocal indentkeys=0{,0},0),0],!^F,o,O,e,:,.

This is how I run vimgolf. I believe this behaviour started with vim8

docker run --rm -it -e "key=..." ghcr.io/filbranden/vimgolf

@sedm0784
Copy link

sedm0784 commented Nov 28, 2024

  filetype=ruby
        Last set from /usr/share/vim/vim91/filetype.vim line 2008

[...]

  2008	au BufNewFile,BufRead *.rb,*.rbw		setf ruby

Okay, so this just means it's setting the filetype because the file has a .rb file extension. I'm a little surprised by this (I don't remember setting a file name when I submitted a challenge, but I've probably just forgotten), but what you're seeing is just regular Vim behaviour.

The most likely explanation I think is that Vim's included Ruby indent script has changed at some point, and the person that submitted the solution you're following was using an older version than you.

Alternatively, it's also possible they were using some kind of non-standard Vim runtime that doesn't result in the regular Ruby indent plugin being used for this file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants