Skip to content
Myr

Ignore punctuation characters before and after preview offset column

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

This is to allow line numbers in a ctags output (e.g. 123;")

authored by Junegunn Choi · committed by Junegunn Choi · parent f092e40 · Browse files · 2 files+13 added−4 removed
This commit

State

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

Diff stats

2 files+13 added−4 removed

  • tests:+6 added−3 removed
  • other:+7 added−1 removed

2 files+13 added−4 removed

modified:src/terminal.go+7 added-1 removed
21 unmodified lines
2223// import "github.com/pkg/profile"2425var placeholder *regexp.Regexp26var numericPrefix *regexp.Regexp27var activeTempFiles []string2829const ellipsis string = ".."3031func init() {32 placeholder = regexp.MustCompile(`\\?(?:{[+sf]*[0-9,-.]*}|{q}|{\+?f?nf?})`)33 numericPrefix = regexp.MustCompile(`^[[:punct:]]*([0-9]+)`)34 activeTempFiles = []string{}35}3637type jumpMode int
1324 unmodified lines
1362}13631364// Ascii to positive integer1365func atopi(s string) int {1364 n, e := strconv.Atoi(strings.ReplaceAll(s, "'", ""))1366 matches := numericPrefix.FindStringSubmatch(s)1367 if len(matches) < 2 {1368 return 01369 }1370 n, e := strconv.Atoi(matches[1])1371 if e != nil || n < 1 {1372 return 01373 }1374 return n
962 unmodified lines
modified:test/test_go.rb+6 added-3 removed
1799 unmodified lines
1800 tmux.until { |lines| assert_match %r{321.*321/1000}, lines[1] }1801 end18021803 def test_preview_scroll_begin_and_offset1804 ['echo foo 123 321', 'echo foo :123: 321'].each do |input|1804 tmux.send_keys "echo foo 123 321 | #{FZF} --preview 'seq 1000' --preview-window left:+{2}-2", :Enter1805 tmux.until { |lines| lines.item_count == 1 }1806 tmux.until { |lines| assert_match %r{121.*121/1000}, lines[1] }1805 tmux.send_keys "#{input} | #{FZF} --preview 'seq 1000' --preview-window left:+{2}-2", :Enter1806 tmux.until { |lines| lines.item_count == 1 }1807 tmux.until { |lines| assert_match %r{121.*121/1000}, lines[1] }1808 tmux.send_keys 'C-c'1809 end1810 end18111812 def test_normalized_match1813 echoes = '(echo a; echo á; echo A; echo Á;)'
484 unmodified lines