@ 261102.1

260810.2 · dab626bd9e0ec17c801f7316a73f7e4a91c1260e

Restore bracketed paste mode instead of forcing it off

Ask the terminal whether the mode is already on (DECRQM) and put it back that way on exit. Forcing it off broke pasting in shells that run fzf from a line editor widget, which enable the mode only when the editor starts. Terminals that do not answer fall back to disabling it.

- Startup queries go out in one write, cursor position last. Every
terminal answers DSR, so its reply bounds the wait: a paste reply
still missing by then means the terminal does not know the query.
- Bound the first read with select(2). Terminals that never answer
escape sequences, such as FreeBSD virtual terminals, blocked startup
until a key was pressed, and that keystroke was then discarded.

Fix #4887 Fix #2860 Fix #976

reading declarations

Changes to src/tui/light_windows.go. All files

src/tui/light_windows.go

@@ -151,6 +151,13 @@ func (r *LightRenderer) findOffset() (row int, col int) { 	return int(bufferInfo.CursorPosition.Y), int(bufferInfo.CursorPosition.X) } +// The console API answers for the cursor, and there is no reply to parse for+// bracketed paste, so fzf keeps disabling the mode on exit here.+func (r *LightRenderer) queryStartup() (row int, col int, pasteWasSet *bool) {+	row, col = r.findOffset()+	return+}+ func (r *LightRenderer) getch(cancellable bool, nonblock bool) (int, getCharResult) { 	if !nonblock && !cancellable { 		bc := <-r.ttyinChannel