mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Use lstrip instead of gsub which can match only once
This commit is contained in:
parent
ee861e43f7
commit
12e06d32f5
2 changed files with 4 additions and 4 deletions
|
@ -123,7 +123,7 @@ class Reline::Config
|
|||
|
||||
no += 1
|
||||
|
||||
line = line.chomp.gsub(/^\s*/, '')
|
||||
line = line.chomp.lstrip
|
||||
if line[0, 1] == '$'
|
||||
handle_directive(line[1..-1], file, no)
|
||||
next
|
||||
|
|
|
@ -800,11 +800,11 @@ class Reline::LineEditor
|
|||
md = new_lines[@line_index].match(/\A */)
|
||||
prev_indent = md[0].count(' ')
|
||||
if @check_new_auto_indent
|
||||
@buffer_of_lines[@line_index] = ' ' * new_indent + @buffer_of_lines[@line_index].gsub(/\A */, '')
|
||||
@buffer_of_lines[@line_index] = ' ' * new_indent + @buffer_of_lines[@line_index].lstrip
|
||||
@cursor = new_indent
|
||||
@byte_pointer = new_indent
|
||||
else
|
||||
@line = ' ' * new_indent + @line.gsub(/\A */, '')
|
||||
@line = ' ' * new_indent + @line.lstrip
|
||||
@cursor += new_indent - prev_indent
|
||||
@byte_pointer += new_indent - prev_indent
|
||||
end
|
||||
|
@ -1893,7 +1893,7 @@ class Reline::LineEditor
|
|||
if @is_multiline and @buffer_of_lines.size > @line_index + 1
|
||||
@cursor = calculate_width(@line)
|
||||
@byte_pointer = @line.bytesize
|
||||
@line += ' ' + @buffer_of_lines.delete_at(@line_index + 1).gsub(/\A +/, '')
|
||||
@line += ' ' + @buffer_of_lines.delete_at(@line_index + 1).lstrip
|
||||
@cursor_max = calculate_width(@line)
|
||||
@buffer_of_lines[@line_index] = @line
|
||||
@rerender_all = true
|
||||
|
|
Loading…
Reference in a new issue