mirror of
https://github.com/zoriya/bubbles.git
synced 2026-08-05 04:36:07 +00:00
Merge remote-tracking branch 'origin/master' into v2-exp
This commit is contained in:
@@ -743,7 +743,7 @@ func (m *Model) deleteWordLeft() {
|
||||
// Linter note: it's critical that we acquire the initial cursor position
|
||||
// here prior to altering it via SetCursor() below. As such, moving this
|
||||
// call into the corresponding if clause does not apply here.
|
||||
oldCol := m.col //nolint:ifshort
|
||||
oldCol := m.col
|
||||
|
||||
m.SetCursorColumn(m.col - 1)
|
||||
for unicode.IsSpace(m.value[m.row][m.col]) {
|
||||
@@ -1383,14 +1383,13 @@ func (m Model) placeholderView() string {
|
||||
case i == 0:
|
||||
// first character of first line as cursor with character
|
||||
m.virtualCursor.TextStyle = styles.computedPlaceholder()
|
||||
m.virtualCursor.SetChar(string(plines[0][0]))
|
||||
|
||||
ch, rest, _, _ := uniseg.FirstGraphemeClusterInString(plines[0], 0)
|
||||
m.virtualCursor.SetChar(ch)
|
||||
s.WriteString(lineStyle.Render(m.virtualCursor.View()))
|
||||
|
||||
// the rest of the first line
|
||||
placeholderTail := plines[0][1:]
|
||||
gap := strings.Repeat(" ", max(0, m.width-uniseg.StringWidth(plines[0])))
|
||||
renderedPlaceholder := styles.computedPlaceholder().Render(placeholderTail + gap)
|
||||
s.WriteString(lineStyle.Render(renderedPlaceholder))
|
||||
s.WriteString(lineStyle.Render(styles.computedPlaceholder().Render(rest)))
|
||||
// remaining lines
|
||||
case len(plines) > i:
|
||||
// current line placeholder text
|
||||
|
||||
@@ -1671,6 +1671,26 @@ func TestView(t *testing.T) {
|
||||
`),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "placeholder chinese character",
|
||||
modelFunc: func(m Model) Model {
|
||||
m.Placeholder = "输入消息..."
|
||||
m.ShowLineNumbers = true
|
||||
m.SetWidth(20)
|
||||
return m
|
||||
},
|
||||
want: want{
|
||||
view: heredoc.Doc(`
|
||||
> 1 输入消息...
|
||||
>
|
||||
>
|
||||
>
|
||||
>
|
||||
>
|
||||
|
||||
`),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
|
||||
@@ -397,7 +397,7 @@ func (m *Model) deleteWordBackward() {
|
||||
// Linter note: it's critical that we acquire the initial cursor position
|
||||
// here prior to altering it via SetCursor() below. As such, moving this
|
||||
// call into the corresponding if clause does not apply here.
|
||||
oldPos := m.pos //nolint:ifshort
|
||||
oldPos := m.pos
|
||||
|
||||
m.SetCursor(m.pos - 1)
|
||||
for unicode.IsSpace(m.value[m.pos]) {
|
||||
|
||||
Reference in New Issue
Block a user