Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions emacs.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package readline
import (
"fmt"
"io"
"slices"
"sort"
"strings"
"unicode"
Expand All @@ -12,6 +13,7 @@ import (
"github.com/reeflective/readline/inputrc"
"github.com/reeflective/readline/internal/color"
"github.com/reeflective/readline/internal/completion"
"github.com/reeflective/readline/internal/core"
"github.com/reeflective/readline/internal/keymap"
"github.com/reeflective/readline/internal/strutil"
"github.com/reeflective/readline/internal/term"
Expand Down Expand Up @@ -448,8 +450,27 @@ func (rl *Shell) selfInsert() {
}

func (rl *Shell) bracketedPasteBegin() {
// keys, _ := rl.Keys.PeekAllBytes()
// fmt.Println(string(keys))
// Length of bracketed paste escape code; this is the minimum length
// we will see here.
sequence := make([]byte, 0, 6)

for {
key, empty := core.PopKey(rl.Keys)
if empty {
core.WaitAvailableKeys(rl.Keys, rl.Config)
continue
}

sequence = append(sequence, key)

if len(sequence) >= 6 && slices.Equal(sequence[len(sequence)-6:], []byte{'\x1b', '[', '2', '0', '1', '~'}) {
break
}
}

if len(sequence) > 6 {
rl.cursor.InsertAt([]rune(string(sequence[:len(sequence)-6]))...)
}
}

// Drag the character before point forward over the character
Expand Down
Loading
Loading