@@ -17,8 +17,8 @@ import (
23 "charm.land/bubbles/v2/help"
23 "charm.land/bubbles/v2/help"
24 "charm.land/bubbles/v2/key"
24 "charm.land/bubbles/v2/key"
@@ -3879,6 +3879,28 @@ func (m *UI) newSession() tea.Cmd {
3882+// checkBangModeAfterPaste engages bang mode when pasted text starts with
3883+// optional whitespace followed by "!". It strips the prefix and adjusts
3884+// the cursor, mirroring the keypress bang-mode entry logic.
3885+func (m *UI) checkBangModeAfterPaste() {
3889+ val := m.textarea.Value()
3890+ trimmed := strings.TrimLeftFunc(val, unicode.IsSpace)
3891+ if !strings.HasPrefix(trimmed, "!") {
3895+ m.bangWasEmpty = true
3896+ stripped := trimmed[1:]
3897+ m.textarea.SetValue(stripped)
3898+ col := m.textarea.Column()
3899+ m.textarea.SetCursorColumn(max(0, col-(len(val)-len(stripped))))
3900+ yolo := m.com.Workspace.PermissionSkipRequests()
3901+ m.setEditorPrompt(yolo)
3882// handlePasteMsg handles a paste message.
3904// handlePasteMsg handles a paste message.
3883func (m *UI) handlePasteMsg(msg tea.PasteMsg) tea.Cmd {
3905func (m *UI) handlePasteMsg(msg tea.PasteMsg) tea.Cmd {
3884 // Normalize \r\n before the textarea sanitizer sees it.
3906 // Normalize \r\n before the textarea sanitizer sees it.
@@ -3939,7 +3961,9 @@ func (m *UI) handlePasteMsg(msg tea.PasteMsg) tea.Cmd {
3940 if !allExistsAndValid() {
3962 if !allExistsAndValid() {
3941 prevHeight := m.textarea.Height()
3963 prevHeight := m.textarea.Height()
3942− return m.updateTextareaWithPrevHeight(msg, prevHeight)
3964+ cmd := m.updateTextareaWithPrevHeight(msg, prevHeight)
3965+ m.checkBangModeAfterPaste()
3945 var cmds []tea.Cmd
3969 var cmds []tea.Cmd