Skip to content
Myr

Don't exit fzf by SIGINT while executing command (#2375)

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

Fix #2374

authored by bitterfox · committed by GitHub · parent bb0502f · Browse files · 2 files+24 added−3 removed
This commit

State

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

Trailers

  • Co-authored-by: Junegunn Choi <junegunn.c@gmail.com>

Diff stats

2 files+24 added−3 removed

  • tests:+11 added−0 removed
  • other:+13 added−3 removed

2 files+24 added−3 removed

modified:src/terminal.go+13 added-3 removed
155 unmodified lines
156 killChan chan int157 slab *util.Slab158 theme *tui.ColorTheme159 tui tui.Renderer160 executing *util.AtomicBool161}162163type selectedItem struct {164 at time.Time
360 unmodified lines
525 theme: opts.Theme,526 startChan: make(chan bool, 1),527 killChan: make(chan int),528 tui: renderer,528 initFunc: func() { renderer.Init() }}529 initFunc: func() { renderer.Init() },530 executing: util.NewAtomicBool(false)}531 t.prompt, t.promptLen = t.parsePrompt(opts.Prompt)532 t.pointer, t.pointerLen = t.processTabs([]rune(opts.Pointer), 0)533 t.marker, t.markerLen = t.processTabs([]rune(opts.Marker), 0)534 // Pre-calculated empty pointer and marker signs
1179 unmodified lines
1714 cmd.Stdin = os.Stdin1715 cmd.Stdout = os.Stdout1716 cmd.Stderr = os.Stderr1717 t.tui.Pause(true)1718 t.executing.Set(true)1719 cmd.Run()1720 t.executing.Set(false)1721 t.tui.Resume(true, false)1722 t.redraw()1723 t.refresh()1724 } else {1725 t.tui.Pause(false)1726 t.executing.Set(true)1727 cmd.Run()1728 t.executing.Set(false)1729 t.tui.Resume(false, false)1730 }1731 cleanTemporaryFiles()1732}
109 unmodified lines
1842 { // Late initialization1843 intChan := make(chan os.Signal, 1)1844 signal.Notify(intChan, os.Interrupt, syscall.SIGTERM)1845 go func() {1840 <-intChan1841 t.reqBox.Set(reqQuit, nil)1846 for s := range intChan {1847 // Don't quit by SIGINT while executing because it should be for the executing command and not for fzf itself1848 if !(s == os.Interrupt && t.executing.Get()) {1849 t.reqBox.Set(reqQuit, nil)1850 }1851 }1852 }()18531854 contChan := make(chan os.Signal, 1)1855 notifyOnCont(contChan)
869 unmodified lines
modified:test/test_go.rb+11 added
1909 unmodified lines
1910 tmux.until { |lines| assert_equal 1, lines.select_count }1911 tmux.send_keys :Down1912 tmux.until { |lines| assert_equal 2, lines.select_count }1913 end19141915 def test_interrupt_execute1916 tmux.send_keys "seq 100 | #{FZF} --bind 'ctrl-l:execute:echo executing {}; sleep 100'", :Enter1917 tmux.until { |lines| assert_equal 100, lines.item_count }1918 tmux.send_keys 'C-l'1919 tmux.until { |lines| assert lines.any_include?('executing 1') }1920 tmux.send_keys 'C-c'1921 tmux.until { |lines| assert_equal 100, lines.item_count }1922 tmux.send_keys 991923 tmux.until { |lines| assert_equal 1, lines.match_count }1924 end1925end19261927module TestShell1928 def setup
478 unmodified lines