Skip to content
Myr

Adjust --no-clear option for repetitive relaunching

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Related: https://gist.github.com/junegunn/4963bab6ace453f7f529d2d0e01b1d85 Close #974

authored by Junegunn Choi · committed by Junegunn Choi · parent 7727ad4 · Browse files · 3 files+32 added−19 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+32 added−19 removed

  • tests:+4 added−3 removed
  • other:+28 added−16 removed

3 files+32 added−19 removed

modified:src/tui/light.go+13 added-7 removed
180 unmodified lines
181182 if r.fullscreen {183 r.smcup()184 } else {185 // We assume that --no-clear is used for repetitive relaunching of fzf.186 // So we do not clear the lower bottom of the screen.187 if r.clearOnExit {185 r.csi("J")188 r.csi("J")189 }190 y, x := r.findOffset()191 r.mouse = r.mouse && y >= 0188 if x > 0 {192 // When --no-clear is used for repetitive relaunching, there is a small193 // time frame between fzf processes where the user keystrokes are not194 // captured by either of fzf process which can cause x offset to be195 // increased and we're left with unwanted extra new line.196 if x > 0 && r.clearOnExit {197 r.upOneLine = true198 r.makeSpace()199 }200 for i := 1; i < r.MaxY(); i++ {
6 unmodified lines
207 }208 r.csi(fmt.Sprintf("%dA", r.MaxY()-1))209 r.csi("G")210 r.csi("K")203 // r.csi("s")211 r.csi("s")212 if !r.fullscreen && r.mouse {213 r.yoffset, _ = r.findOffset()214 }215}
377 unmodified lines
593 r.csi("A")594 }595 r.csi("J")596 }589 } else if r.fullscreen {590 r.csi("G")591 } else {592 r.move(r.height, 0)597 } else if !r.fullscreen {598 r.csi("u")599 }600 if r.mouse {601 r.csi("?1000l")602 }
292 unmodified lines
modified:src/terminal.go+15 added-9 removed
85 unmodified lines
86 tabstop int87 margin [4]sizeSpec88 strong tui.Attr89 bordered bool90 cleanExit bool91 border tui.Window92 window tui.Window93 pborder tui.Window94 pwindow tui.Window
271 unmodified lines
366 printQuery: opts.PrintQuery,367 history: opts.History,368 margin: opts.Margin,369 bordered: opts.Bordered,370 cleanExit: opts.ClearOnExit,371 strong: strongAttr,372 cycle: opts.Cycle,373 header: header,374 header0: header,
967 unmodified lines
1342 }1343 }()1344 }13451344 exit := func(code int) {1346 exit := func(code int, printQuery bool) {1347 if !t.cleanExit && t.fullscreen && t.inlineInfo {1348 t.placeCursor()1349 }1350 t.tui.Close()1351 if printQuery {1352 t.printer(string(t.input))1353 }1354 if code <= exitNoMatch && t.history != nil {1355 t.history.append(string(t.input))1356 }1357 // prof.Stop()
39 unmodified lines
1397 t.redraw()1398 case reqRedraw:1399 t.redraw()1400 case reqClose:1392 t.tui.Close()1401 if t.output() {1394 exit(exitOk)1402 exit(exitOk, false)1403 } else {1404 exit(exitNoMatch, false)1405 }1396 exit(exitNoMatch)1406 case reqPreviewDisplay:1407 t.previewer.text = value.(string)1408 t.previewer.lines = strings.Count(t.previewer.text, "\n")1409 t.previewer.offset = 01410 t.printPreview()1411 case reqPreviewRefresh:1412 t.printPreview()1413 case reqPrintQuery:1405 t.tui.Close()1406 t.printer(string(t.input))1407 exit(exitOk)1414 exit(exitOk, true)1415 case reqQuit:1409 t.tui.Close()1410 exit(exitInterrupt)1416 exit(exitInterrupt, false)1417 }1418 }1419 t.placeCursor()1420 t.mutex.Unlock()
424 unmodified lines
modified:test/test_go.rb+4 added-3 removed
1251 unmodified lines
1252 tmux.until { |_| %w[1 2 3] == File.readlines(tempname).map(&:chomp) }1253 end12541255 def test_no_clear1256 tmux.send_keys 'seq 100 | fzf --no-clear --inline-info --height 5', :Enter1257 prompt = '> < 100/100'1256 tmux.send_keys "seq 10 | fzf --no-clear --inline-info --height 5 > #{tempname}", :Enter1257 prompt = '> < 10/10'1258 tmux.until { |lines| lines[-1] == prompt }1259 tmux.send_keys :Enter1260 tmux.until { |lines| lines[-2] == prompt && lines[-1] == '1' }1260 tmux.until { |_| %w[1] == File.readlines(tempname).map(&:chomp) }1261 tmux.until { |lines| lines[-1] == prompt }1262 end12631264 def test_change_top1265 tmux.send_keys %[seq 1000 | #{FZF} --bind change:top], :Enter
363 unmodified lines