Projects STRLCPY fzf Commits 92b7efaf
🤬
  • Ignore punctuation characters before and after preview offset column

    This is to allow line numbers in a ctags output (e.g. 123;")
  • Loading...
  • Junegunn Choi committed 4 years ago
    92b7efaf
    1 parent f092e403
Revision indexing in progress... (symbol navigation in revisions will be accurate after indexed)
  • ■ ■ ■ ■ ■
    src/terminal.go
    skipped 22 lines
    23 23  // import "github.com/pkg/profile"
    24 24   
    25 25  var placeholder *regexp.Regexp
     26 +var numericPrefix *regexp.Regexp
    26 27  var activeTempFiles []string
    27 28   
    28 29  const ellipsis string = ".."
    29 30   
    30 31  func init() {
    31 32   placeholder = regexp.MustCompile(`\\?(?:{[+sf]*[0-9,-.]*}|{q}|{\+?f?nf?})`)
     33 + numericPrefix = regexp.MustCompile(`^[[:punct:]]*([0-9]+)`)
    32 34   activeTempFiles = []string{}
    33 35  }
    34 36   
    skipped 1326 lines
    1361 1363   
    1362 1364  // Ascii to positive integer
    1363 1365  func atopi(s string) int {
    1364  - n, e := strconv.Atoi(strings.ReplaceAll(s, "'", ""))
     1366 + matches := numericPrefix.FindStringSubmatch(s)
     1367 + if len(matches) < 2 {
     1368 + return 0
     1369 + }
     1370 + n, e := strconv.Atoi(matches[1])
    1365 1371   if e != nil || n < 1 {
    1366 1372   return 0
    1367 1373   }
    skipped 964 lines
  • ■ ■ ■ ■ ■ ■
    test/test_go.rb
    skipped 1800 lines
    1801 1801   end
    1802 1802   
    1803 1803   def test_preview_scroll_begin_and_offset
    1804  - tmux.send_keys "echo foo 123 321 | #{FZF} --preview 'seq 1000' --preview-window left:+{2}-2", :Enter
    1805  - tmux.until { |lines| lines.item_count == 1 }
    1806  - tmux.until { |lines| assert_match %r{121.*121/1000}, lines[1] }
     1804 + ['echo foo 123 321', 'echo foo :123: 321'].each do |input|
     1805 + tmux.send_keys "#{input} | #{FZF} --preview 'seq 1000' --preview-window left:+{2}-2", :Enter
     1806 + 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 + end
    1807 1810   end
    1808 1811   
    1809 1812   def test_normalized_match
    skipped 486 lines
Please wait...
Page is in error, reload to recover