Complete indented and quoted string correctly
def foo ''.upca[TAB] This will be completed to be: def foo ''.upcase The indent was gone. This commit fixes the bug.
This commit is contained in:
parent
da028a4fbf
commit
439e1ccd08
@ -905,7 +905,6 @@ class Reline::LineEditor
|
|||||||
quote = nil
|
quote = nil
|
||||||
i += 1
|
i += 1
|
||||||
rest = nil
|
rest = nil
|
||||||
break_pointer = nil
|
|
||||||
elsif quote and slice.start_with?(escaped_quote)
|
elsif quote and slice.start_with?(escaped_quote)
|
||||||
# skip
|
# skip
|
||||||
i += 2
|
i += 2
|
||||||
@ -915,7 +914,7 @@ class Reline::LineEditor
|
|||||||
closing_quote = /(?!\\)#{Regexp.escape(quote)}/
|
closing_quote = /(?!\\)#{Regexp.escape(quote)}/
|
||||||
escaped_quote = /\\#{Regexp.escape(quote)}/
|
escaped_quote = /\\#{Regexp.escape(quote)}/
|
||||||
i += 1
|
i += 1
|
||||||
break_pointer = i
|
break_pointer = i - 1
|
||||||
elsif not quote and slice =~ word_break_regexp
|
elsif not quote and slice =~ word_break_regexp
|
||||||
rest = $'
|
rest = $'
|
||||||
i += 1
|
i += 1
|
||||||
@ -937,6 +936,11 @@ class Reline::LineEditor
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
preposing = ''
|
preposing = ''
|
||||||
|
if break_pointer
|
||||||
|
preposing = @line.byteslice(0, break_pointer)
|
||||||
|
else
|
||||||
|
preposing = ''
|
||||||
|
end
|
||||||
target = before
|
target = before
|
||||||
end
|
end
|
||||||
[preposing.encode(@encoding), target.encode(@encoding), postposing.encode(@encoding)]
|
[preposing.encode(@encoding), target.encode(@encoding), postposing.encode(@encoding)]
|
||||||
|
@ -1325,6 +1325,37 @@ class Reline::KeyActor::Emacs::Test < Reline::TestCase
|
|||||||
assert_line('foo_ba')
|
assert_line('foo_ba')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_completion_with_indent
|
||||||
|
@line_editor.completion_proc = proc { |word|
|
||||||
|
%w{
|
||||||
|
foo_foo
|
||||||
|
foo_bar
|
||||||
|
foo_baz
|
||||||
|
qux
|
||||||
|
}.map { |i|
|
||||||
|
i.encode(@encoding)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
input_keys(' fo')
|
||||||
|
assert_byte_pointer_size(' fo')
|
||||||
|
assert_cursor(4)
|
||||||
|
assert_cursor_max(4)
|
||||||
|
assert_line(' fo')
|
||||||
|
assert_equal(nil, @line_editor.instance_variable_get(:@menu_info))
|
||||||
|
input_keys("\C-i", false)
|
||||||
|
assert_byte_pointer_size(' foo_')
|
||||||
|
assert_cursor(6)
|
||||||
|
assert_cursor_max(6)
|
||||||
|
assert_line(' foo_')
|
||||||
|
assert_equal(nil, @line_editor.instance_variable_get(:@menu_info))
|
||||||
|
input_keys("\C-i", false)
|
||||||
|
assert_byte_pointer_size(' foo_')
|
||||||
|
assert_cursor(6)
|
||||||
|
assert_cursor_max(6)
|
||||||
|
assert_line(' foo_')
|
||||||
|
assert_equal(%w{foo_foo foo_bar foo_baz}, @line_editor.instance_variable_get(:@menu_info).list)
|
||||||
|
end
|
||||||
|
|
||||||
def test_completion_with_indent_and_completer_quote_characters
|
def test_completion_with_indent_and_completer_quote_characters
|
||||||
@line_editor.completion_proc = proc { |word|
|
@line_editor.completion_proc = proc { |word|
|
||||||
%w{
|
%w{
|
||||||
@ -1336,11 +1367,11 @@ class Reline::KeyActor::Emacs::Test < Reline::TestCase
|
|||||||
i.encode(@encoding)
|
i.encode(@encoding)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
input_keys(' "".foo_')
|
input_keys(' "".fo')
|
||||||
assert_byte_pointer_size(' "".foo_')
|
assert_byte_pointer_size(' "".fo')
|
||||||
assert_cursor(9)
|
assert_cursor(7)
|
||||||
assert_cursor_max(9)
|
assert_cursor_max(7)
|
||||||
assert_line(' "".foo_')
|
assert_line(' "".fo')
|
||||||
assert_equal(nil, @line_editor.instance_variable_get(:@menu_info))
|
assert_equal(nil, @line_editor.instance_variable_get(:@menu_info))
|
||||||
input_keys("\C-i", false)
|
input_keys("\C-i", false)
|
||||||
assert_byte_pointer_size(' "".foo_')
|
assert_byte_pointer_size(' "".foo_')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user