Skip to content

Commit 0f2646a

Browse files
authored
Merge pull request #143 from clawscli/fix/suggestion-width
fix: maintain input width when showing suggestion
2 parents 2dc5a6b + 60a3925 commit 0f2646a

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

internal/view/command_input.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,15 @@ func (c *CommandInput) renderInputWithSuggestion(s commandInputStyles, input str
254254
// Remove trailing padding from textinput so suggestion appears right after cursor
255255
trimmedView := strings.TrimRight(baseView, " ")
256256

257-
// Render: trimmed input + dim suffix (within same input box style)
258-
return s.input.Render(trimmedView + s.suggestion.Render(suffix))
257+
// Restore padding after suffix to maintain original width
258+
removedPadding := len(baseView) - len(trimmedView)
259+
paddingNeeded := removedPadding - len(suffix)
260+
if paddingNeeded < 0 {
261+
paddingNeeded = 0
262+
}
263+
264+
// Render: trimmed input + dim suffix + padding (within same input box style)
265+
return s.input.Render(trimmedView + s.suggestion.Render(suffix) + strings.Repeat(" ", paddingNeeded))
259266
}
260267

261268
// View renders the command input

0 commit comments

Comments
 (0)