is this a bug?

1 view
Skip to first unread message

Boyko Bantchev

unread,
Aug 28, 2008, 5:44:18 PM8/28/08
to v...@vim.org
A week ago I posted a question about some strange
behaviour of a simple Vim script. It can be found here:

http://article.gmane.org/gmane.editors.vim/68893

Since nobody replied then, I am asking again:
please somebody say, is this a bug, and if not, how
it can be explained? Thank you.
Best regards,
Boyko

Benjamin Fritz

unread,
Aug 28, 2008, 6:16:03 PM8/28/08
to vim...@googlegroups.com

Wow, that is strange.

For those who don't want to follow the link...

Vim code:

try | while 1
let s:s = input('')
echo "\n".s:s
endw | catch | endt


Input the following text, pressing <enter> after each line:

abcd
ef
ghijk
lmnopqr
stuv

You will see:

(first line blanked)
abcd
ef
ef
gh
ghijk
lmnop
lmnopqr
stuv
stuv

One would expect to see:

abcd
abcd
ef
ef
ghijk
ghijk
lmnopqr
lmnopqr
stuv
stuv

My Vim version:

VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Aug 22 2008 10:02:37)
MS-Windows 32-bit GUI version with OLE support
Included patches: 1-2
Compiled by digit...@SPAMdancingpaper.com
Big version with GUI. Features included (+) or not (-):
+arabic +autocmd +balloon_eval +browse ++builtin_terms +byte_offset +cindent
+clientserver +clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments
+cryptv +cscope +cursorshape +dialog_con_gui +diff +digraphs -dnd -ebcdic
+emacs_tags +eval +ex_extra +extra_search +farsi +file_in_path +find_in_path
+float +folding -footer +gettext/dyn -hangul_input +iconv/dyn +insert_expand
+jumplist +keymap +langmap +libcall +linebreak +lispindent +listcmds +localmap
+menu +mksession +modify_fname +mouse +mouseshape +multi_byte_ime/dyn
+multi_lang +mzscheme/dyn +netbeans_intg +ole -osfiletype +path_extra +perl/dyn
-postscript +printer -profile +python/dyn +quickfix +reltime +rightleft
+ruby/dyn +scrollbind +signs +smartindent -sniff +statusline -sun_workshop
+syntax +tag_binary +tag_old_static -tag_any_white +tcl/dyn -tgetent
-termresponse +textobjects +title +toolbar +user_commands +vertsplit
+virtualedit +visual +visualextra +viminfo +vreplace +wildignore +wildmenu
+windows +writebackup -xfontset -xim -xterm_save -xpm_w32
system vimrc file: "$VIM\vimrc"
user vimrc file: "$HOME\_vimrc"
2nd user vimrc file: "$VIM\_vimrc"
user exrc file: "$HOME\_exrc"
2nd user exrc file: "$VIM\_exrc"
system gvimrc file: "$VIM\gvimrc"
user gvimrc file: "$HOME\_gvimrc"
2nd user gvimrc file: "$VIM\_gvimrc"
system menu file: "$VIMRUNTIME\menu.vim"
Compilation: gcc -O3 -fomit-frame-pointer -freg-struct-return
-fno-strength-reduce -DWIN32 -DHAVE_PATHDEF -DFEAT_BIG -DWINVER=0x0400
-D_WIN32_WINNT=0x0400 -DFEAT_PERL -DDYNAMIC_PERL
-DDYNAMIC_PERL_DLL="perl58.dll" -DFEAT_PYTHON -DDYNAMIC_PYTHON
-DDYNAMIC_PYTHON_DLL="python25.dll" -DFEAT_RUBY -DDYNAMIC_RUBY
-DDYNAMIC_RUBY_DLL="msvcrt-ruby18.dll" -DDYNAMIC_RUBY_VER=18
-DFEAT_MZSCHEME -DDYNAMIC_MZSCHEME
-DDYNAMIC_MZSCH_DLL="libmzsch370.dll"
-DDYNAMIC_MZGC_DLL="libmzgc370.dll" -DFEAT_TCL -DDYNAMIC_TCL
-DDYNAMIC_TCL_DLL="tcl84.dll" -DDYNAMIC_GETTEXT -DDYNAMIC_ICONV
-DFEAT_MBYTE -DFEAT_MBYTE_IME -DDYNAMIC_IME -DFEAT_CSCOPE
-DFEAT_NETBEANS_INTG -DFEAT_GUI_W32 -DFEAT_CLIPBOARD -DFEAT_OLE
-march=i386 -Iproto -I/cygdrive/c/PERL/lib/CORE
-I/cygdrive/c/PYTHON25/include
-I/cygdrive/c/RUBY/lib/ruby/1.8/i386-mswin32
-I/cygdrive/c/PROGRA~1/MzScheme/include -I/cygdrive/c/Tcl/include -s
-mno-cygwin
Linking: gcc -s -o gvim.exe -luuid -lole32
/cygdrive/c/Tcl/lib/tclstub84.lib -lwsock32 -mwindows -lcomctl32
-lversion -loleaut32 -lstdc++

Erik Falor

unread,
Aug 28, 2008, 11:00:04 PM8/28/08
to vim...@googlegroups.com

Reproduced on Linux as well.




VIM - Vi IMproved 7.2b BETA (2008 Jul 13, compiled Jul 25 2008 01:56:15)
Included patches: 1-10
Compiled by fade-in@gemini
Normal version with GTK2 GUI. Features included (+) or not (-):
-arabic +autocmd +balloon_eval +browse +builtin_terms +byte_offset +cindent 


+clientserver +clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments +cryptv 

-cscope +cursorshape +dialog_con_gui +diff +digraphs +dnd -ebcdic -emacs_tags +eval 
+ex_extra +extra_search -farsi +file_in_path +find_in_path +float +folding -footer 
+fork() +gettext -hangul_input +iconv +insert_expand +jumplist -keymap -langmap 


+libcall +linebreak +lispindent +listcmds +localmap +menu +mksession +modify_fname 

+mouse +mouseshape -mouse_dec +mouse_gpm -mouse_jsbterm -mouse_netterm -mouse_sysmouse 
+mouse_xterm +multi_byte +multi_lang -mzscheme +netbeans_intg -osfiletype +path_extra 
-perl +postscript +printer -profile -python +quickfix +reltime -rightleft -ruby 


+scrollbind +signs +smartindent -sniff +statusline -sun_workshop +syntax +tag_binary 

+tag_old_static -tag_any_white -tcl +terminfo +termresponse +textobjects +title 


+toolbar +user_commands +vertsplit +virtualedit +visual +visualextra +viminfo +vreplace

 +wildignore +wildmenu +windows +writebackup +X11 -xfontset +xim +xsmp_interact 
+xterm_clipboard -xterm_save 
  system vimrc file: "$VIM/vimrc"
  user vimrc file: "$HOME/.vimrc"
  user exrc file: "$HOME/.exrc"
  system gvimrc file: "$VIM/gvimrc"
  user gvimrc file: "$HOME/.gvimrc"
  system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/usr/local/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK -I/usr/include/gtk-2.0 -I/usr/lib64/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/pixman-1 -g -O2 -I/usr/include64  
Linking: gcc -L/usr/lib64 -L/usr/local/lib -o vim -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -lglib-2.0 -lXt -lm -lncurses -lgpm  


Ouch.  Looks like I gotta recompile... been out of Beta for a while now.

--
Erik Falor
Registered Linux User #445632 http://counter.li.org

Bram Moolenaar

unread,
Sep 1, 2008, 10:45:02 AM9/1/08
to Boyko Bantchev, v...@vim.org

Boyko Bantchev wrote:

It looks like calling input() changes the column that :echo uses.
It doesn't look right.

--
How To Keep A Healthy Level Of Insanity:
3. Every time someone asks you to do something, ask if they want fries
with that.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ download, build and distribute -- http://www.A-A-P.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Ben Schmidt

unread,
Sep 2, 2008, 7:59:54 AM9/2/08
to vim...@googlegroups.com
> It looks like calling input() changes the column that :echo uses.
> It doesn't look right.

The problem is that getcmdline_prompt saves and restores msg_col. It
does this so that if it is called while a commandline is being edited
(e.g. if you use CTRL-R = to enter an expression and then that
expression uses input()) the commandline being edited is properly
restored, along with the record of its column. But we don't want that
if the input() prompt is staying on the screen because a commandline
*isn't* being edited already.

Here's a patch. I think it's good: there are relatively few code paths
that lead to this function, and I think I understand what's going on,
but you might like to look at it carefully, Bram, as I'm not completely
confident it won't have other side effects, or that the assumption holds
that cmdbuff == NULL is true iff a commandline is not being edited.

Ben.

diff -r d0671563949f src/ex_getln.c
--- a/src/ex_getln.c Thu Aug 14 11:28:45 2008 +1000
+++ b/src/ex_getln.c Tue Sep 02 21:55:23 2008 +1000
@@ -1951,8 +1951,11 @@
# endif
s = getcmdline(firstc, 1L, 0);
restore_cmdline(&save_ccline);
- /* Restore msg_col, the prompt from input() may have changed it. */
- msg_col = msg_col_save;
+ /* Restore msg_col, the prompt from input() may have changed it.
+ But only do it if called recursively and the commandline is
+ therefore being restored to an old one; if not, the input() prompt
+ stays on the screen, so we need its modified msg_col left intact. */
+ if (ccline.cmdbuff != NULL) msg_col = msg_col_save;

return s;
}

Reply all
Reply to author
Forward
0 new messages