Skip to content

Commit

Permalink
Makes linter happy
Browse files Browse the repository at this point in the history
  • Loading branch information
ksysoev committed Oct 18, 2023
1 parent 0172546 commit ec963be
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions pkg/cli/editor.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,14 @@ func (ed *Editor) removeSymbol() {
ed.pos--
symbol := ed.buffer[ed.pos]
buffer := ed.buffer[:ed.pos]

if ed.pos < (len(ed.buffer) - 1) {
buffer = append(buffer, ed.buffer[ed.pos+1:]...)
}

ed.buffer = buffer

if symbol == '\n' {

fmt.Print(LineUp)

startPrevLine := LastIndexOf(ed.buffer, ed.pos, '\n')
Expand All @@ -162,20 +163,21 @@ func (ed *Editor) InsertSymbol(symbol rune) {
buffer := ed.buffer[:ed.pos]
buffer = append(buffer, symbol)
endOfStr := ""

if ed.pos < len(ed.buffer) {
buffer = append(buffer, ed.buffer[ed.pos:]...)

moveCursor := ""

for i := ed.pos; i < len(ed.buffer); i++ {
if ed.buffer[i] == '\n' {
break
} else {
if ed.buffer[i] != '\n' {
endOfStr += string(ed.buffer[i])
moveCursor += "\b"
}
}

endOfStr += moveCursor
}

ed.buffer = buffer
ed.pos++

Expand Down

0 comments on commit ec963be

Please sign in to comment.