reline 0.5.4 → 0.5.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 45922535b3972631020c6b33bc6b88fd400062fb2c0820ab95ab991704c1fc42
4
- data.tar.gz: 53f36ad5e7e196ba34a22990c32b38556653b7384bd99108a791d1b4c7cd3b36
3
+ metadata.gz: 590a83a7301ffc23869017938e580376b9e3025130ebb0f102fa47d5ac9be28f
4
+ data.tar.gz: 4652d400dba7e688591f1795e1c2a42b51ce4c9ad8381420c56e68c167034535
5
5
  SHA512:
6
- metadata.gz: eb1b50add8dc60baeefd1fecce83abbaf0e134c16c30ca7fd268efe46d364638280bd2a16100e54be6dbf691bc8a9d4220c53210233a06a0278361c07bd5a56f
7
- data.tar.gz: 5ed4f57373cd6e9329de58b9361037e4f8e510020c0ba59970de5733a8c8f4b5c004b871d8e21f013ee065daed9b55f433142529b5e4039276a0f0adbc00c4d9
6
+ metadata.gz: 9d3272d6b13d84818a895910d2a0201fa1629ea0dfc71037904a9c5f862c277866780df9aad323a5898941c9f2162fa2684892451617b30e7b9ec637ec3c143d
7
+ data.tar.gz: 67004e4bf5b626ebf7d098750ffa7b198539ae8d344ad65b80f101faef0f0f57504e05cd2cd90a167feaea0f6a78c179abd1d698cecb29c290a7d2dbac3923ae
data/lib/reline/config.rb CHANGED
@@ -69,17 +69,14 @@ class Reline::Config
69
69
  @test_mode = false
70
70
  @autocompletion = false
71
71
  @convert_meta = true if seven_bit_encoding?(Reline::IOGate.encoding)
72
+ @loaded = false
72
73
  end
73
74
 
74
75
  def reset
75
76
  if editing_mode_is?(:vi_command)
76
77
  @editing_mode_label = :vi_insert
77
78
  end
78
- @additional_key_bindings.keys.each do |key|
79
- @additional_key_bindings[key].clear
80
- end
81
79
  @oneshot_key_bindings.clear
82
- reset_default_key_bindings
83
80
  end
84
81
 
85
82
  def editing_mode
@@ -98,6 +95,10 @@ class Reline::Config
98
95
  @key_actors[@keymap_label]
99
96
  end
100
97
 
98
+ def loaded?
99
+ @loaded
100
+ end
101
+
101
102
  def inputrc_path
102
103
  case ENV['INPUTRC']
103
104
  when nil, ''
@@ -129,6 +130,7 @@ class Reline::Config
129
130
  end
130
131
 
131
132
  def read(file = nil)
133
+ @loaded = true
132
134
  file ||= default_inputrc_path
133
135
  begin
134
136
  if file.respond_to?(:readlines)
@@ -171,12 +173,6 @@ class Reline::Config
171
173
  @key_actors[@keymap_label].default_key_bindings[keystroke] = target
172
174
  end
173
175
 
174
- def reset_default_key_bindings
175
- @key_actors.values.each do |ka|
176
- ka.reset_default_key_bindings
177
- end
178
- end
179
-
180
176
  def read_lines(lines, file = nil)
181
177
  if not lines.empty? and lines.first.encoding != Reline.encoding_system_needs
182
178
  begin
@@ -12,8 +12,4 @@ class Reline::KeyActor::Base
12
12
  def default_key_bindings
13
13
  @default_key_bindings
14
14
  end
15
-
16
- def reset_default_key_bindings
17
- @default_key_bindings.clear
18
- end
19
15
  end
@@ -387,7 +387,7 @@ class Reline::LineEditor
387
387
  next cached
388
388
  end
389
389
  *wrapped_prompts, code_line_prompt = split_by_width(prompt, width).first.compact
390
- wrapped_lines = split_by_width(line, width, offset: calculate_width(code_line_prompt)).first.compact
390
+ wrapped_lines = split_by_width(line, width, offset: calculate_width(code_line_prompt, true)).first.compact
391
391
  wrapped_prompts.map { |p| [p, ''] } + [[code_line_prompt, wrapped_lines.first]] + wrapped_lines.drop(1).map { |c| ['', c] }
392
392
  end
393
393
  end
@@ -1,3 +1,3 @@
1
1
  module Reline
2
- VERSION = '0.5.4'
2
+ VERSION = '0.5.5'
3
3
  end
data/lib/reline.rb CHANGED
@@ -225,17 +225,20 @@ module Reline
225
225
  journey_data = completion_journey_data
226
226
  return unless journey_data
227
227
 
228
- target = journey_data.list[journey_data.pointer]
228
+ target = journey_data.list.first
229
+ completed = journey_data.list[journey_data.pointer]
229
230
  result = journey_data.list.drop(1)
230
231
  pointer = journey_data.pointer - 1
231
- return if target.empty? || (result == [target] && pointer < 0)
232
+ return if completed.empty? || (result == [completed] && pointer < 0)
232
233
 
233
234
  target_width = Reline::Unicode.calculate_width(target)
234
- x = cursor_pos.x - target_width
235
- if x < 0
236
- x = screen_width + x
235
+ completed_width = Reline::Unicode.calculate_width(completed)
236
+ if cursor_pos.x <= completed_width - target_width
237
+ # When target is rendered on the line above cursor position
238
+ x = screen_width - completed_width
237
239
  y = -1
238
240
  else
241
+ x = [cursor_pos.x - completed_width, 0].max
239
242
  y = 0
240
243
  end
241
244
  cursor_pos_to_render = Reline::CursorPos.new(x, y)
@@ -335,9 +338,8 @@ module Reline
335
338
  end
336
339
  end
337
340
 
338
- unless config.test_mode
341
+ unless config.test_mode or config.loaded?
339
342
  config.read
340
- config.reset_default_key_bindings
341
343
  io_gate.set_default_key_bindings(config)
342
344
  end
343
345
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reline
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.4
4
+ version: 0.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - aycabta
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-04-29 00:00:00.000000000 Z
11
+ date: 2024-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: io-console
@@ -76,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
76
76
  - !ruby/object:Gem::Version
77
77
  version: '0'
78
78
  requirements: []
79
- rubygems_version: 3.5.3
79
+ rubygems_version: 3.5.9
80
80
  signing_key:
81
81
  specification_version: 4
82
82
  summary: Alternative GNU Readline or Editline implementation by pure Ruby.