mirror of
https://github.com/zoriya/bubbles.git
synced 2026-08-06 21:26:11 +00:00
fix(textarea): fix data corruption after multi-line input
Previously, when inserting multiple lines of input at once, the underlying Go data array was incorrectly shared in memory across multiple rows of the textarea. This was causing input corruption, where a user trying to modify one line would see their text added on the next line as well. This patch fixes it.
This commit is contained in:
committed by
Maas Lalani
parent
db06ae17d3
commit
ee382285e7
@@ -321,7 +321,11 @@ func (m *Model) insertRunesFromUserInput(runes []rune) {
|
||||
lstart := 0
|
||||
for i := 0; i < len(runes); i++ {
|
||||
if runes[i] == '\n' {
|
||||
lines = append(lines, runes[lstart:i])
|
||||
// Queue a line to become a new row in the text area below.
|
||||
// Beware to clamp the max capacity of the slice, to ensure no
|
||||
// data from different rows get overwritten when later edits
|
||||
// will modify this line.
|
||||
lines = append(lines, runes[lstart:i:i])
|
||||
lstart = i + 1
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user