mirror of https://github.com/chzyer/readline.git
fix: when input contains character where width > 1, such like chinese, cursor will in a wrong place, and never can back to the sentence`s head
This commit is contained in:
parent
2972be24d4
commit
e668c71600
|
@ -527,8 +527,10 @@ func (r *RuneBuffer) getBackspaceSequence() []byte {
|
|||
}
|
||||
var buf []byte
|
||||
for i := len(r.buf); i > r.idx; i-- {
|
||||
// move input to the left of one
|
||||
// move input to the left of one, fix character where width > 1, such like chinese
|
||||
for j:=0;j<runes.Width(r.buf[i-1]);j++ {
|
||||
buf = append(buf, '\b')
|
||||
}
|
||||
if sep[i] {
|
||||
// up one line, go to the start of the line and move cursor right to the end (r.width)
|
||||
buf = append(buf, "\033[A\r"+"\033["+strconv.Itoa(r.width)+"C"...)
|
||||
|
|
Loading…
Reference in New Issue