mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	[ruby/reline] Return 1 when char width not found
This fixes ruby/reline#261.
3cf1213014
			
			
This commit is contained in:
		
							parent
							
								
									b88be10094
								
							
						
					
					
						commit
						dc9e33016c
					
				
					 2 changed files with 9 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -108,6 +108,7 @@ class Reline::Unicode
 | 
			
		|||
    end
 | 
			
		||||
    m = mbchar.encode(Encoding::UTF_8).match(MBCharWidthRE)
 | 
			
		||||
    case
 | 
			
		||||
    when m.nil? then 1 # TODO should be U+FFFD <20> REPLACEMENT CHARACTER
 | 
			
		||||
    when m[:width_2_1], m[:width_2_2] then 2
 | 
			
		||||
    when m[:width_3] then 3
 | 
			
		||||
    when m[:width_0] then 0
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2280,6 +2280,14 @@ class Reline::KeyActor::Emacs::Test < Reline::TestCase
 | 
			
		|||
    assert_line('  12345')
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_input_unknown_char
 | 
			
		||||
    input_keys('') # U+0378 (unassigned)
 | 
			
		||||
    assert_line('')
 | 
			
		||||
    assert_byte_pointer_size('')
 | 
			
		||||
    assert_cursor(1)
 | 
			
		||||
    assert_cursor_max(1)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
=begin # TODO: move KeyStroke instance from Reline to LineEditor
 | 
			
		||||
  def test_key_delete
 | 
			
		||||
    input_keys('ab')
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue