Skip to content

Commit

Permalink
In go_to_char functions, gracefully handle the pressing of Esc, Ctrl-…
Browse files Browse the repository at this point in the history
…C, and other "lower ASCII" values.
  • Loading branch information
Pistos committed May 2, 2014
1 parent 6767f25 commit 8364ba1
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions lib/diakonos/functions/cursor.rb
Expand Up @@ -161,9 +161,14 @@ def go_to_char( after = nil, char = nil )
char ||= get_char( "Type character to go to..." )

if char
moved = buffer_current.go_to_char( char, after == :after ? AFTER_CHAR : ON_CHAR )
if ! moved
set_iline "'#{char}' not found."
begin
moved = buffer_current.go_to_char( char, after == :after ? AFTER_CHAR : ON_CHAR )
if ! moved
set_iline "'#{char}' not found."
end
rescue TypeError
# User pressed Esc, or Ctrl-C, or similar.
# Quietly continue.
end
end
end
Expand All @@ -174,10 +179,14 @@ def go_to_char_previous( after = nil, char = nil )
char ||= get_char( "Type character to go to..." )

if char

moved = buffer_current.go_to_char_previous( char, after == :after ? AFTER_CHAR : ON_CHAR )
if ! moved
set_iline "'#{char}' not found."
begin
moved = buffer_current.go_to_char_previous( char, after == :after ? AFTER_CHAR : ON_CHAR )
if ! moved
set_iline "'#{char}' not found."
end
rescue TypeError
# User pressed Esc, or Ctrl-C, or similar.
# Quietly continue.
end
end
end
Expand Down

0 comments on commit 8364ba1

Please sign in to comment.