mirror of
https://github.com/ruby/ruby.git
synced 2025-08-27 06:56:13 +02:00
[ruby/reline] Refactor perform_completon
(https://github.com/ruby/reline/pull/778)
Flatten recursive method
Remove CompletionState::COMPLETE
aa5b278f3d
This commit is contained in:
parent
3ac5c05327
commit
25d17868de
4 changed files with 83 additions and 87 deletions
|
@ -633,6 +633,19 @@ class Reline::Unicode
|
|||
byte_size
|
||||
end
|
||||
|
||||
def self.common_prefix(list, ignore_case: false)
|
||||
return '' if list.empty?
|
||||
|
||||
common_prefix_gcs = list.first.grapheme_clusters
|
||||
list.each do |item|
|
||||
gcs = item.grapheme_clusters
|
||||
common_prefix_gcs = common_prefix_gcs.take_while.with_index do |gc, i|
|
||||
ignore_case ? gc.casecmp?(gcs[i]) : gc == gcs[i]
|
||||
end
|
||||
end
|
||||
common_prefix_gcs.join
|
||||
end
|
||||
|
||||
def self.vi_first_print(line)
|
||||
byte_size = 0
|
||||
while (line.bytesize - 1) > byte_size
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue