Make sure that the query before the cursor is not hidden

Close #3176
This commit is contained in:
Junegunn Choi 2023-02-19 16:38:26 +09:00
parent 352ea07226
commit b1459c79cf
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627

View File

@ -1338,8 +1338,7 @@ func (t *Terminal) updatePromptOffset() ([]rune, []rune) {
_, overflow := t.trimLeft(t.input[:t.cx], maxWidth) _, overflow := t.trimLeft(t.input[:t.cx], maxWidth)
minOffset := int(overflow) minOffset := int(overflow)
maxOffset := util.Min(util.Min(len(t.input), minOffset+maxWidth), t.cx) maxOffset := minOffset + (maxWidth-util.Max(0, maxWidth-t.cx))/2
t.xoffset = util.Constrain(t.xoffset, minOffset, maxOffset) t.xoffset = util.Constrain(t.xoffset, minOffset, maxOffset)
before, _ := t.trimLeft(t.input[t.xoffset:t.cx], maxWidth) before, _ := t.trimLeft(t.input[t.xoffset:t.cx], maxWidth)
beforeLen := t.displayWidth(before) beforeLen := t.displayWidth(before)