mirror of
https://github.com/junegunn/fzf.git
synced 2026-08-12 19:07:00 +08:00
@@ -26,6 +26,7 @@ CHANGELOG
|
|||||||
- Improved the cache structure, reducing memory footprint per entry by 86x.
|
- Improved the cache structure, reducing memory footprint per entry by 86x.
|
||||||
- With the reduced per-entry cost, the cache now has broader coverage.
|
- With the reduced per-entry cost, the cache now has broader coverage.
|
||||||
- fish: Improved command history (CTRL-R) (#4703) (@bitraid)
|
- fish: Improved command history (CTRL-R) (#4703) (@bitraid)
|
||||||
|
- `GET /` HTTP endpoint now includes `positions` field in each match entry, providing the indices of matched characters for external highlighting (#4726)
|
||||||
- Bug fixes
|
- Bug fixes
|
||||||
- `--walker=follow` no longer follows symlinks whose target is an ancestor of the walker root, avoiding severe resource exhaustion when a symlink points outside the tree (e.g. Wine's `z:` → `/`) (#4710)
|
- `--walker=follow` no longer follows symlinks whose target is an ancestor of the walker root, avoiding severe resource exhaustion when a symlink points outside the tree (e.g. Wine's `z:` → `/`) (#4710)
|
||||||
- Fixed AWK tokenizer not treating a new line character as whitespace
|
- Fixed AWK tokenizer not treating a new line character as whitespace
|
||||||
|
|||||||
+12
-3
@@ -216,8 +216,9 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type StatusItem struct {
|
type StatusItem struct {
|
||||||
Index int `json:"index"`
|
Index int `json:"index"`
|
||||||
Text string `json:"text"`
|
Text string `json:"text"`
|
||||||
|
Positions []int `json:"positions,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Status struct {
|
type Status struct {
|
||||||
@@ -7869,10 +7870,18 @@ func (t *Terminal) dumpItem(i *Item) StatusItem {
|
|||||||
if i == nil {
|
if i == nil {
|
||||||
return StatusItem{}
|
return StatusItem{}
|
||||||
}
|
}
|
||||||
return StatusItem{
|
item := StatusItem{
|
||||||
Index: int(i.Index()),
|
Index: int(i.Index()),
|
||||||
Text: i.AsString(t.ansi),
|
Text: i.AsString(t.ansi),
|
||||||
}
|
}
|
||||||
|
if t.resultMerger.pattern != nil {
|
||||||
|
_, _, pos := t.resultMerger.pattern.MatchItem(i, true, t.slab)
|
||||||
|
if pos != nil {
|
||||||
|
sort.Ints(*pos)
|
||||||
|
item.Positions = *pos
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return item
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Terminal) tryLock(timeout time.Duration) bool {
|
func (t *Terminal) tryLock(timeout time.Duration) bool {
|
||||||
|
|||||||
@@ -16,6 +16,31 @@ class TestServer < TestInteractive
|
|||||||
assert_empty state[:query]
|
assert_empty state[:query]
|
||||||
assert_equal({ index: 0, text: '1' }, state[:current])
|
assert_equal({ index: 0, text: '1' }, state[:current])
|
||||||
|
|
||||||
|
# No positions when query is empty
|
||||||
|
state[:matches].each do |m|
|
||||||
|
assert_nil m[:positions]
|
||||||
|
end
|
||||||
|
assert_nil state[:current][:positions] if state[:current]
|
||||||
|
|
||||||
|
# Positions with a single-character query
|
||||||
|
Net::HTTP.post(fn.call, 'change-query(1)')
|
||||||
|
tmux.until { |lines| assert_equal 2, lines.match_count }
|
||||||
|
state = JSON.parse(Net::HTTP.get(fn.call), symbolize_names: true)
|
||||||
|
assert_equal [0], state[:current][:positions]
|
||||||
|
state[:matches].each do |m|
|
||||||
|
assert_includes m[:text], '1'
|
||||||
|
assert_equal [m[:text].index('1')], m[:positions]
|
||||||
|
end
|
||||||
|
|
||||||
|
# Positions with a multi-character query; verify sorted ascending
|
||||||
|
Net::HTTP.post(fn.call, 'change-query(10)')
|
||||||
|
tmux.until { |lines| assert_equal 1, lines.match_count }
|
||||||
|
state = JSON.parse(Net::HTTP.get(fn.call), symbolize_names: true)
|
||||||
|
assert_equal '10', state[:current][:text]
|
||||||
|
assert_equal [0, 1], state[:current][:positions]
|
||||||
|
assert_equal state[:current][:positions], state[:current][:positions].sort
|
||||||
|
|
||||||
|
# No match — no current item
|
||||||
Net::HTTP.post(fn.call, 'change-query(yo)+reload(seq 100)+change-prompt:hundred> ')
|
Net::HTTP.post(fn.call, 'change-query(yo)+reload(seq 100)+change-prompt:hundred> ')
|
||||||
tmux.until { |lines| assert_equal 100, lines.item_count }
|
tmux.until { |lines| assert_equal 100, lines.item_count }
|
||||||
tmux.until { |lines| assert_equal 'hundred> yo', lines[-1] }
|
tmux.until { |lines| assert_equal 'hundred> yo', lines[-1] }
|
||||||
|
|||||||
Reference in New Issue
Block a user