m/fzf
1
0
mirror of https://github.com/junegunn/fzf.git synced 2025-11-15 14:53:47 -05:00

Compare commits

...

4 Commits

Author SHA1 Message Date
Junegunn Choi
7fa5e6c861 0.15.1 2016-09-21 01:28:24 +09:00
Junegunn Choi
00f96aae76 Avoid rendering delay when displaying extremely long lines
Related #666
2016-09-21 01:23:41 +09:00
Junegunn Choi
a749e6bd16 Fix temp directory in a test case 2016-09-21 01:15:35 +09:00
Junegunn Choi
791076d366 Fix panic when pattern occurs after 2^15-th column
Fix #666
2016-09-21 01:15:06 +09:00
9 changed files with 36 additions and 13 deletions

View File

@@ -1,6 +1,11 @@
CHANGELOG CHANGELOG
========= =========
0.15.1
------
- Fixed panic when the pattern occurs after 2^15-th column
- Fixed rendering delay when displaying extremely long lines
0.15.0 0.15.0
------ ------
- Improved fuzzy search algorithm - Improved fuzzy search algorithm

View File

@@ -2,8 +2,8 @@
set -u set -u
[[ "$@" =~ --pre ]] && version=0.15.0 pre=1 || [[ "$@" =~ --pre ]] && version=0.15.1 pre=1 ||
version=0.15.0 pre=0 version=0.15.1 pre=0
auto_completion= auto_completion=
key_bindings= key_bindings=

View File

@@ -21,7 +21,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
.. ..
.TH fzf-tmux 1 "Sep 2016" "fzf 0.15.0" "fzf-tmux - open fzf in tmux split pane" .TH fzf-tmux 1 "Sep 2016" "fzf 0.15.1" "fzf-tmux - open fzf in tmux split pane"
.SH NAME .SH NAME
fzf-tmux - open fzf in tmux split pane fzf-tmux - open fzf in tmux split pane

View File

@@ -21,7 +21,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
.. ..
.TH fzf 1 "Sep 2016" "fzf 0.15.0" "fzf - a command-line fuzzy finder" .TH fzf 1 "Sep 2016" "fzf 0.15.1" "fzf - a command-line fuzzy finder"
.SH NAME .SH NAME
fzf - a command-line fuzzy finder fzf - a command-line fuzzy finder

View File

@@ -257,13 +257,14 @@ func FuzzyMatchV2(caseSensitive bool, forward bool, input util.Chars, pattern []
} }
// Reuse pre-allocated integer slice to avoid unnecessary sweeping of garbages // Reuse pre-allocated integer slice to avoid unnecessary sweeping of garbages
offset := 0 offset16 := 0
offset32 := 0
// Bonus point for each position // Bonus point for each position
offset, B := alloc16(offset, slab, N, false) offset16, B := alloc16(offset16, slab, N, false)
// The first occurrence of each character in the pattern // The first occurrence of each character in the pattern
offset, F := alloc16(offset, slab, M, false) offset32, F := alloc32(offset32, slab, M, false)
// Rune array // Rune array
_, T := alloc32(0, slab, N, false) offset32, T := alloc32(offset32, slab, N, false)
// Phase 1. Check if there's a match and calculate bonus for each point // Phase 1. Check if there's a match and calculate bonus for each point
pidx, lastIdx, prevClass := 0, 0, charNonWord pidx, lastIdx, prevClass := 0, 0, charNonWord
@@ -291,7 +292,7 @@ func FuzzyMatchV2(caseSensitive bool, forward bool, input util.Chars, pattern []
if pidx < M { if pidx < M {
if char == pattern[pidx] { if char == pattern[pidx] {
lastIdx = idx lastIdx = idx
F[pidx] = int16(idx) F[pidx] = int32(idx)
pidx++ pidx++
} }
} else { } else {
@@ -307,10 +308,10 @@ func FuzzyMatchV2(caseSensitive bool, forward bool, input util.Chars, pattern []
// Phase 2. Fill in score matrix (H) // Phase 2. Fill in score matrix (H)
// Unlike the original algorithm, we do not allow omission. // Unlike the original algorithm, we do not allow omission.
width := lastIdx - int(F[0]) + 1 width := lastIdx - int(F[0]) + 1
offset, H := alloc16(offset, slab, width*M, false) offset16, H := alloc16(offset16, slab, width*M, false)
// Possible length of consecutive chunk at each position. // Possible length of consecutive chunk at each position.
offset, C := alloc16(offset, slab, width*M, false) offset16, C := alloc16(offset16, slab, width*M, false)
maxScore, maxScorePos := int16(0), 0 maxScore, maxScorePos := int16(0), 0
for i := 0; i < M; i++ { for i := 0; i < M; i++ {

View File

@@ -1,6 +1,7 @@
package algo package algo
import ( import (
"math"
"sort" "sort"
"strings" "strings"
"testing" "testing"
@@ -154,3 +155,12 @@ func TestEmptyPattern(t *testing.T) {
assertMatch(t, SuffixMatch, true, dir, "foobar", "", 6, 6, 0) assertMatch(t, SuffixMatch, true, dir, "foobar", "", 6, 6, 0)
} }
} }
func TestLongString(t *testing.T) {
bytes := make([]byte, math.MaxUint16*2)
for i := range bytes {
bytes[i] = 'x'
}
bytes[math.MaxUint16] = 'z'
assertMatch(t, FuzzyMatchV2, true, true, string(bytes), "zx", math.MaxUint16, math.MaxUint16+2, scoreMatch*2+bonusConsecutive)
}

View File

@@ -8,7 +8,7 @@ import (
const ( const (
// Current version // Current version
version = "0.15.0" version = "0.15.1"
// Core // Core
coordinatorDelayMax time.Duration = 100 * time.Millisecond coordinatorDelayMax time.Duration = 100 * time.Millisecond

View File

@@ -342,7 +342,7 @@ func TestDefaultCtrlNP(t *testing.T) {
check([]string{"--bind=ctrl-n:accept"}, curses.CtrlN, actAccept) check([]string{"--bind=ctrl-n:accept"}, curses.CtrlN, actAccept)
check([]string{"--bind=ctrl-p:accept"}, curses.CtrlP, actAccept) check([]string{"--bind=ctrl-p:accept"}, curses.CtrlP, actAccept)
hist := "--history=/tmp/foo" hist := "--history=/tmp/fzf-history"
check([]string{hist}, curses.CtrlN, actNextHistory) check([]string{hist}, curses.CtrlN, actNextHistory)
check([]string{hist}, curses.CtrlP, actPreviousHistory) check([]string{hist}, curses.CtrlP, actPreviousHistory)

View File

@@ -401,6 +401,8 @@ func displayWidth(runes []rune) int {
const ( const (
minWidth = 16 minWidth = 16
minHeight = 4 minHeight = 4
maxDisplayWidthCalc = 1024
) )
func calculateSize(base int, size sizeSpec, margin int, minSize int) int { func calculateSize(base int, size sizeSpec, margin int, minSize int) int {
@@ -651,6 +653,11 @@ func displayWidthWithLimit(runes []rune, prefixWidth int, limit int) int {
} }
func trimLeft(runes []rune, width int) ([]rune, int32) { func trimLeft(runes []rune, width int) ([]rune, int32) {
if len(runes) > maxDisplayWidthCalc && len(runes) > width {
trimmed := len(runes) - width
return runes[trimmed:], int32(trimmed)
}
currentWidth := displayWidth(runes) currentWidth := displayWidth(runes)
var trimmed int32 var trimmed int32