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

Keeps asking question when closing vim #94

Closed
marlun opened this issue Jul 8, 2012 · 26 comments · Fixed by #95
Closed

Keeps asking question when closing vim #94

marlun opened this issue Jul 8, 2012 · 26 comments · Fixed by #95

Comments

@marlun
Copy link

marlun commented Jul 8, 2012

Hi,

When I'm finished golfing and close vim there seems to be a loop asking me if I want to see a diff, retry or quit and the only way I can stop it is hitting ctrl-c. Looks like thiss:

Downloading Vimgolf challenge: 4ff83e9749534f000100003f
Launching VimGolf session for challenge: 4ff83e9749534f000100003f
Uh oh, looks like your entry does not match the desired output.
Would you like to see a [d]iff or [r]etry or [q]uit ?
Would you like to see a [d]iff or [r]etry or [q]uit ?
Would you like to see a [d]iff or [r]etry or [q]uit ?
Would you like to see a [d]iff or [r]etry or [q]uit ?
Would you like to see a [d]iff or [r]etry or [q]uit ?
Would you like to see a [d]iff or [r]etry or [q]uit ?
.
. (Keeps writing this until I hit ctrl-c)
.
Would you like to see a [d]iff or [r]etry or [q]uit ?
^CUh oh, something went wrong! Error: If the error persists, please report it to github.com/igrigorik/vimgolf

If I try hitting d, r or q nothing happends, it just keeps asking. I'm on OSX 10.7.4.

@marlun
Copy link
Author

marlun commented Jul 10, 2012

Here's a video of it happening: http://d.pr/v/Gflj

@igrigorik
Copy link
Owner

Whoa, that's bizzarre. How are you exiting vim? :wq or ZZ? It's as if you have a stuck key in there.

@marlun
Copy link
Author

marlun commented Jul 10, 2012

I'm exiting with ZZ but the same thing happends if I exit it using :wq

I've tried running vimgolf put 4ff83e9749534f000100003f in both iTerm2 and Terminal in OS X.

I've installed a seperate (from osx default) vim using homebrew and I've checked :version when in vimgolf and it's using the homebrew installed vim.

@igrigorik
Copy link
Owner

Perhaps an issue with Thor? Which version are you on, and can you try updating? gem update thor..

@marlun
Copy link
Author

marlun commented Jul 10, 2012

Updated Thor but still getting the same problem. I tried vimgolf on my other laptop, it had an earlier version which it told me to update so I did and then I tried and I'm getting the exact same problem on that laptop.

Here's the log on updating thor:

Updating installed gems
Updating thor
Successfully installed thor-0.15.4
Gems updated: thor
Installing ri documentation for thor-0.15.4...
Installing RDoc documentation for thor-0.15.4...

@igrigorik
Copy link
Owner

Can't reproduce here.. Upgraded to latest also, works fine. =/

igrigorik { ~ } > vimgolf put 4ff83e9749534f000100003f
Downloading Vimgolf challenge: 4ff83e9749534f000100003f
Launching VimGolf session for challenge: 4ff83e9749534f000100003f
Uh oh, looks like your entry does not match the desired output.
Would you like to see a [d]iff or [r]etry or [q]uit ?
n
You must choose one of [:diff, :retry, :quit].
?  diff
Showing vimdiff of your attempt (left) and correct output (right)
2 files to edit
Would you like to see a [d]iff or [r]etry or [q]uit ?
q
Please try again! Your score for this (failed) attempt was: 3

@marlun
Copy link
Author

marlun commented Jul 11, 2012

I thought it could've been something in my .bashrc or .inputrc but I removed them and the result is the same.

I also tried changing my PATH so that vimgolf used the default OS X installation of vim but the same thing happend. Very weird.

@michaelmior
Copy link

I have the same issue here. If there's any helpful info I can provide, let me know. Here's my vim info for a start

VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Jul 31 2011 19:27:29) Compiled by root@apple.com Normal version without GUI. Features included (+) or not (-): -arabic +autocmd -balloon_eval -browse +builtin_terms +byte_offset +cindent -clientserver -clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments -conceal +cryptv +cscope +cursorbind +cursorshape +dialog_con +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 -lua +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 +persistent_undo +postscript +printer -profile -python -python3 +quickfix +reltime -rightleft -ruby +scrollbind +signs +smartindent -sniff +startuptime +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 -xterm_clipboard -xterm_save system vimrc file: "$VIM/vimrc" user vimrc file: "$HOME/.vimrc" user exrc file: "$HOME/.exrc" fall-back for $VIM: "/usr/share/vim" Compilation: gcc -c -I. -D_FORTIFY_SOURCE=0 -Iproto -DHAVE_CONFIG_H -arch i386 -arch x86_64 -g -Os -pipe Linking: gcc -arch i386 -arch x86_64 -o vim -lncurses

@igrigorik
Copy link
Owner

I don't think this is a Vim issue, this is likely a bug we may have introduced in the recent CLI refactoring: 14a69fd /cc @fgalassi

Would one of you guys be willing to instrument your clients and print out what exactly what's happening in there?

The code we're after is likely in: https://github.com/igrigorik/vimgolf/blob/master/lib/vimgolf/ui.rb#L53

Can you add some extra logging in there to see what input you're actually getting? Perhaps it's the EOF rescue?

@michaelmior
Copy link

Yup, I'm seeing the EOFError repeatedly. If I change the return statement in the rescue to return :quit, it exits as expected.

@igrigorik
Copy link
Owner

Can you try replacing the body of that method with older version and see if that fixes it?

begin
    require 'highline'
    @hl ||= HighLine.new($stdin)
    if not $stdin.tty?
      @hl.ask(message)
    elsif password
      @hl.ask(message) {|q| q.echo = "*" }
    else
      @hl.ask(message) {|q| q.readline = true }
    end
  rescue EOFError
    return ''
  end
end

@marlun
Copy link
Author

marlun commented Jul 11, 2012

Would love to help but unfortunately I don't know what to do to "instrument my client"?

@michaelmior
Copy link

Adding HighLine.track_eof = false in the initializer solves this for me. I'll try your code above.

@michaelmior
Copy link

With your code above, I get

Uh oh, something went wrong! Error: undefined local variable or method `password' for #<VimGolf::CLI::UI:0x106257c20>

@fgalassi
Copy link
Contributor

guys, which version of ruby do you have?

@michaelmior
Copy link

ruby 1.8.7 (2011-12-28 patchlevel 357) [universal-darwin11.0]

@marlun
Copy link
Author

marlun commented Jul 11, 2012

I get the same error message when I switch the code and I also have

ruby 1.8.7 (2011-12-28 patchlevel 357) [universal-darwin11.0]

@fgalassi
Copy link
Contributor

ok, i can reproduce the problem. It looks like it could be stock ruby on snow leopard and the highline ruby library, which vimgolf uses. I am going to look into this, but if you wanna try in the meantime i think installing ruby with homebrew gonna fix this

@michaelmior
Copy link

@marlun If you add HighLine.track_eof = false in the initializer (right underneath @hl = ...) at the top of the file, does that solve for you also?

@marlun
Copy link
Author

marlun commented Jul 11, 2012

@michaelmior like this:?

def initialize
    super
    @hl = HighLine.new($stdin)
    HighLine.track_eof = false
end

@fgalassi
Copy link
Contributor

yes it works. Need to look around on the web if there's some possible problem with that and check no regressions on linux, then i think i can pull. ok Ilya?

@fgalassi
Copy link
Contributor

@marlun yes

@marlun
Copy link
Author

marlun commented Jul 11, 2012

@fgalassi @michaelmior Yes, adding that and having the original ask_question content seem to solve the problem :)

@fgalassi
Copy link
Contributor

Ok works for me, pulled, thank you all.

(and never trust apple stock ruby)

@marlun
Copy link
Author

marlun commented Jul 11, 2012

Great, thanks for the help all of you! Now I can get back to fine tuning my vim skills.

@igrigorik
Copy link
Owner

Awesome, thanks for figuring this out guys! @fgalassi pull looks good, left a quick note about an additional message on exception.

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

Successfully merging a pull request may close this issue.

4 participants