[ruby/reline] Refactor perform_completon

(https://github.com/ruby/reline/pull/778)

Flatten recursive method
Remove CompletionState::COMPLETE

aa5b278f3d
This commit is contained in:
tomoya ishida 2024-11-12 00:31:01 +09:00 committed by git
parent 3ac5c05327
commit 25d17868de
4 changed files with 83 additions and 87 deletions

View file

@ -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