Skip to content
Myr

Fix #209 - Invalid mutation of input on case conversion

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

authored by Junegunn Choi · committed by Junegunn Choi · parent 917b175 · Browse files · 2 files+17 added−2 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+17 added−2 removed

  • tests:+10 added−0 removed
  • other:+7 added−2 removed

2 files+17 added−2 removed

modified:src/algo/algo.go+7 added-2 removed
40 unmodified lines
41 // difference in CPU cost. (Measured on Go 1.4.1. Also note that the Go42 // compiler as of now does not inline non-leaf functions.)43 if char >= 'A' && char <= 'Z' {44 char += 3245 (*runes)[index] = char45 } else if char > unicode.MaxASCII {46 char = unicode.To(unicode.LowerCase, char)48 (*runes)[index] = char47 }48 }49 if char == pattern[pidx] {50 if sidx < 0 {
9 unmodified lines
60 if sidx >= 0 && eidx >= 0 {61 pidx--62 for index := eidx - 1; index >= sidx; index-- {63 char := (*runes)[index]64 if !caseSensitive {65 if char >= 'A' && char <= 'Z' {66 char += 3267 } else if char > unicode.MaxASCII {68 char = unicode.To(unicode.LowerCase, char)69 }70 }71 if char == pattern[pidx] {72 if pidx--; pidx < 0 {73 sidx = index74 break
87 unmodified lines
modified:test/test_go.rb+10 added
523 unmodified lines
524 rescue525 File.unlink tempname526 end527528 def test_invalid_cache529 tmux.send_keys "(echo d; echo D; echo x) | #{fzf '-q d'}", :Enter530 tmux.until { |lines| lines[-2].include? '2/3' }531 tmux.send_keys :BSpace532 tmux.until { |lines| lines[-2].include? '3/3' }533 tmux.send_keys :D534 tmux.until { |lines| lines[-2].include? '1/3' }535 tmux.send_keys :Enter536 end537538private539 def writelines path, lines, timeout = 10540 File.open(path, 'w') do |f|541 f << lines.join($/)
166 unmodified lines