Drop an invalid char as UTF-8
This commit is contained in:
parent
729b7ce270
commit
778634f778
@ -1091,6 +1091,11 @@ class Reline::LineEditor
|
|||||||
|
|
||||||
private def ed_insert(key)
|
private def ed_insert(key)
|
||||||
if key.instance_of?(String)
|
if key.instance_of?(String)
|
||||||
|
begin
|
||||||
|
key.encode(Encoding::UTF_8)
|
||||||
|
rescue Encoding::UndefinedConversionError
|
||||||
|
return
|
||||||
|
end
|
||||||
width = Reline::Unicode.get_mbchar_width(key)
|
width = Reline::Unicode.get_mbchar_width(key)
|
||||||
if @cursor == @cursor_max
|
if @cursor == @cursor_max
|
||||||
@line += key
|
@line += key
|
||||||
@ -1101,6 +1106,11 @@ class Reline::LineEditor
|
|||||||
@cursor += width
|
@cursor += width
|
||||||
@cursor_max += width
|
@cursor_max += width
|
||||||
else
|
else
|
||||||
|
begin
|
||||||
|
key.chr.encode(Encoding::UTF_8)
|
||||||
|
rescue Encoding::UndefinedConversionError
|
||||||
|
return
|
||||||
|
end
|
||||||
if @cursor == @cursor_max
|
if @cursor == @cursor_max
|
||||||
@line += key.chr
|
@line += key.chr
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user