mirror of
https://github.com/junegunn/fzf.git
synced 2026-08-12 19:07:00 +08:00
Clean up non-ascii characters
This commit is contained in:
+7
-7
@@ -309,16 +309,16 @@ I know it's a lot to digest, let's try to break down the code.
|
|||||||
available color options.
|
available color options.
|
||||||
- The value of `--preview-window` option consists of 5 components delimited
|
- The value of `--preview-window` option consists of 5 components delimited
|
||||||
by `,`
|
by `,`
|
||||||
1. `up` — Position of the preview window
|
1. `up` -- Position of the preview window
|
||||||
1. `60%` — Size of the preview window
|
1. `60%` -- Size of the preview window
|
||||||
1. `border-bottom` — Preview window border only on the bottom side
|
1. `border-bottom` -- Preview window border only on the bottom side
|
||||||
1. `+{2}+3/3` — Scroll offset of the preview contents
|
1. `+{2}+3/3` -- Scroll offset of the preview contents
|
||||||
1. `~3` — Fixed header
|
1. `~3` -- Fixed header
|
||||||
- Let's break down the latter two. We want to display the bat output in the
|
- Let's break down the latter two. We want to display the bat output in the
|
||||||
preview window with a certain scroll offset so that the matching line is
|
preview window with a certain scroll offset so that the matching line is
|
||||||
positioned near the center of the preview window.
|
positioned near the center of the preview window.
|
||||||
- `+{2}` — The base offset is extracted from the second token
|
- `+{2}` -- The base offset is extracted from the second token
|
||||||
- `+3` — We add 3 lines to the base offset to compensate for the header
|
- `+3` -- We add 3 lines to the base offset to compensate for the header
|
||||||
part of `bat` output
|
part of `bat` output
|
||||||
- ```
|
- ```
|
||||||
───────┬──────────────────────────────────────────────────────────
|
───────┬──────────────────────────────────────────────────────────
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
<a href="https://commitgoods.com/collections/fzf"><img src="https://junegunn.github.io/fzf/images/fzf-mugs.jpg" width="80%" alt="fzf merch"></a>
|
<a href="https://commitgoods.com/collections/fzf"><img src="https://junegunn.github.io/fzf/images/fzf-mugs.jpg" width="80%" alt="fzf merch"></a>
|
||||||
<br/>
|
<br/>
|
||||||
<br/>
|
<br/>
|
||||||
Show your love for fzf — T-shirts, mugs, and stickers now available!
|
Show your love for fzf -- T-shirts, mugs, and stickers now available!
|
||||||
<br/>
|
<br/>
|
||||||
<br/>
|
<br/>
|
||||||
<a href="https://commitgoods.com/collections/fzf">commitgoods.com/collections/fzf</a>
|
<a href="https://commitgoods.com/collections/fzf">commitgoods.com/collections/fzf</a>
|
||||||
@@ -37,10 +37,10 @@ characters and still get the results you want.
|
|||||||
Highlights
|
Highlights
|
||||||
----------
|
----------
|
||||||
|
|
||||||
- **Portable** — Distributed as a single binary for easy installation
|
- **Portable** -- Distributed as a single binary for easy installation
|
||||||
- **Fast** — Optimized to process millions of items instantly
|
- **Fast** -- Optimized to process millions of items instantly
|
||||||
- **Versatile** — Fully customizable through an event-action binding mechanism
|
- **Versatile** -- Fully customizable through an event-action binding mechanism
|
||||||
- **All-inclusive** — Comes with integrations for Bash, Zsh, Fish, Vim, and Neovim
|
- **All-inclusive** -- Comes with integrations for Bash, Zsh, Fish, Vim, and Neovim
|
||||||
|
|
||||||
Table of Contents
|
Table of Contents
|
||||||
-----------------
|
-----------------
|
||||||
@@ -440,7 +440,7 @@ or `py`.
|
|||||||
|
|
||||||
The user interface of fzf is fully customizable with a large number of
|
The user interface of fzf is fully customizable with a large number of
|
||||||
configuration options. For a quick setup, you can start with one of the style
|
configuration options. For a quick setup, you can start with one of the style
|
||||||
presets — `default`, `full`, or `minimal` — using the `--style` option.
|
presets -- `default`, `full`, or `minimal` -- using the `--style` option.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
fzf --style full \
|
fzf --style full \
|
||||||
|
|||||||
+5
-5
@@ -2,10 +2,10 @@
|
|||||||
|
|
||||||
## What these functions do
|
## What these functions do
|
||||||
|
|
||||||
`indexByteTwo(s []byte, b1, b2 byte) int` — returns the index of the
|
`indexByteTwo(s []byte, b1, b2 byte) int` -- returns the index of the
|
||||||
**first** occurrence of `b1` or `b2` in `s`, or `-1`.
|
**first** occurrence of `b1` or `b2` in `s`, or `-1`.
|
||||||
|
|
||||||
`lastIndexByteTwo(s []byte, b1, b2 byte) int` — returns the index of the
|
`lastIndexByteTwo(s []byte, b1, b2 byte) int` -- returns the index of the
|
||||||
**last** occurrence of `b1` or `b2` in `s`, or `-1`.
|
**last** occurrence of `b1` or `b2` in `s`, or `-1`.
|
||||||
|
|
||||||
They are used by the fuzzy matching algorithm (`algo.go`) to skip ahead
|
They are used by the fuzzy matching algorithm (`algo.go`) to skip ahead
|
||||||
@@ -91,9 +91,9 @@ implementations (`2xIndexByte` using `bytes.IndexByte`, and a simple `loop`).
|
|||||||
|
|
||||||
The assembly is verified by three layers of testing:
|
The assembly is verified by three layers of testing:
|
||||||
|
|
||||||
1. **Table-driven tests** — known inputs with expected outputs.
|
1. **Table-driven tests** -- known inputs with expected outputs.
|
||||||
2. **Exhaustive tests** — all lengths 0–256, every match position, no-match
|
2. **Exhaustive tests** -- all lengths 0–256, every match position, no-match
|
||||||
cases, and both-bytes-present cases, compared against a simple loop
|
cases, and both-bytes-present cases, compared against a simple loop
|
||||||
reference.
|
reference.
|
||||||
3. **Fuzz tests** — randomized inputs via `testing.F`, compared against the
|
3. **Fuzz tests** -- randomized inputs via `testing.F`, compared against the
|
||||||
same loop reference.
|
same loop reference.
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ loop:
|
|||||||
CBZ R6, loop
|
CBZ R6, loop
|
||||||
|
|
||||||
end:
|
end:
|
||||||
// Found something or out of data — build full syndrome
|
// Found something or out of data, build full syndrome
|
||||||
VAND V5.B16, V3.B16, V3.B16
|
VAND V5.B16, V3.B16, V3.B16
|
||||||
VAND V5.B16, V4.B16, V4.B16
|
VAND V5.B16, V4.B16, V4.B16
|
||||||
VADDP V4.B16, V3.B16, V6.B16
|
VADDP V4.B16, V3.B16, V6.B16
|
||||||
|
|||||||
+1
-1
@@ -484,7 +484,7 @@ func interpretCode(ansiCode string, prevState *ansiState) ansiState {
|
|||||||
state.attr = state.attr | tui.Italic
|
state.attr = state.attr | tui.Italic
|
||||||
case 4:
|
case 4:
|
||||||
if sep == ':' {
|
if sep == ':' {
|
||||||
// SGR 4:N — underline style sub-parameter
|
// SGR 4:N - underline style sub-parameter
|
||||||
var subNum int
|
var subNum int
|
||||||
subNum, _, ansiCode = parseAnsiCode(ansiCode)
|
subNum, _, ansiCode = parseAnsiCode(ansiCode)
|
||||||
state.attr = state.attr &^ tui.UnderlineStyleMask
|
state.attr = state.attr &^ tui.UnderlineStyleMask
|
||||||
|
|||||||
@@ -721,7 +721,7 @@ func TestWordWrapAnsiLine(t *testing.T) {
|
|||||||
t.Errorf("ANSI: %q", result)
|
t.Errorf("ANSI: %q", result)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Long word (no space) — no break, let character wrapping handle it
|
// Long word (no space) - no break, let character wrapping handle it
|
||||||
result = term.wordWrapAnsiLine("abcdefghij", 5, 2)
|
result = term.wordWrapAnsiLine("abcdefghij", 5, 2)
|
||||||
if len(result) != 1 || result[0] != "abcdefghij" {
|
if len(result) != 1 || result[0] != "abcdefghij" {
|
||||||
t.Errorf("Long word: %q", result)
|
t.Errorf("Long word: %q", result)
|
||||||
@@ -749,7 +749,7 @@ func TestWordWrapAnsiLine(t *testing.T) {
|
|||||||
|
|
||||||
// Tab handling: tab expands to tabstop-aligned width
|
// Tab handling: tab expands to tabstop-aligned width
|
||||||
term.tabstop = 8
|
term.tabstop = 8
|
||||||
// "\thi there" — tab at column 0 expands to 8, total "hi" starts at 8
|
// "\thi there" - tab at column 0 expands to 8, total "hi" starts at 8
|
||||||
// maxWidth=15: "\thi" = 10 wide, "there" = 5 wide, total 16 > 15, wrap at space
|
// maxWidth=15: "\thi" = 10 wide, "there" = 5 wide, total 16 > 15, wrap at space
|
||||||
result = term.wordWrapAnsiLine("\thi there", 15, 2)
|
result = term.wordWrapAnsiLine("\thi there", 15, 2)
|
||||||
if len(result) != 2 || result[0] != "\thi" || result[1] != "there" {
|
if len(result) != 2 || result[0] != "\thi" || result[1] != "there" {
|
||||||
|
|||||||
+1
-1
@@ -9,7 +9,7 @@ func TestWrapLine(t *testing.T) {
|
|||||||
t.Errorf("Basic wrap: %v", lines)
|
t.Errorf("Basic wrap: %v", lines)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Exact fit — no wrapping needed
|
// Exact fit - no wrapping needed
|
||||||
lines = WrapLine("hello", 0, 5, 8, 2)
|
lines = WrapLine("hello", 0, 5, 8, 2)
|
||||||
if len(lines) != 1 || lines[0].Text != "hello" || lines[0].DisplayWidth != 5 {
|
if len(lines) != 1 || lines[0].Text != "hello" || lines[0].DisplayWidth != 5 {
|
||||||
t.Errorf("Exact fit: %v", lines)
|
t.Errorf("Exact fit: %v", lines)
|
||||||
|
|||||||
+9
-9
@@ -1672,7 +1672,7 @@ class TestCore < TestInteractive
|
|||||||
end
|
end
|
||||||
tmux.send_keys :BSpace, :BSpace, :BSpace
|
tmux.send_keys :BSpace, :BSpace, :BSpace
|
||||||
|
|
||||||
# Reload with shuffled order — cursor should track "555"
|
# Reload with shuffled order - cursor should track "555"
|
||||||
tmux.send_keys 'C-r'
|
tmux.send_keys 'C-r'
|
||||||
tmux.until do |lines|
|
tmux.until do |lines|
|
||||||
assert_equal 1000, lines.match_count
|
assert_equal 1000, lines.match_count
|
||||||
@@ -1694,7 +1694,7 @@ class TestCore < TestInteractive
|
|||||||
tmux.send_keys :Up
|
tmux.send_keys :Up
|
||||||
tmux.until { |lines| assert_includes lines, '> 2 banana' }
|
tmux.until { |lines| assert_includes lines, '> 2 banana' }
|
||||||
|
|
||||||
# Reload — the second field changes, but first field "2" stays
|
# Reload - the second field changes, but first field "2" stays
|
||||||
tmux.send_keys 'C-r'
|
tmux.send_keys 'C-r'
|
||||||
tmux.until do |lines|
|
tmux.until do |lines|
|
||||||
assert_equal 3, lines.match_count
|
assert_equal 3, lines.match_count
|
||||||
@@ -1709,7 +1709,7 @@ class TestCore < TestInteractive
|
|||||||
tmux.send_keys :Up
|
tmux.send_keys :Up
|
||||||
tmux.until { |lines| assert_includes lines, '> beta' }
|
tmux.until { |lines| assert_includes lines, '> beta' }
|
||||||
|
|
||||||
# Reload with completely different items — no match for "beta"
|
# Reload with completely different items - no match for "beta"
|
||||||
# Cursor stays at the same position (second item)
|
# Cursor stays at the same position (second item)
|
||||||
tmux.send_keys 'C-r'
|
tmux.send_keys 'C-r'
|
||||||
tmux.until do |lines|
|
tmux.until do |lines|
|
||||||
@@ -1727,7 +1727,7 @@ class TestCore < TestInteractive
|
|||||||
assert_includes lines[-2], '+T'
|
assert_includes lines[-2], '+T'
|
||||||
end
|
end
|
||||||
|
|
||||||
# Trigger slow reload — should show +T* while blocked
|
# Trigger slow reload - should show +T* while blocked
|
||||||
tmux.send_keys 'C-r'
|
tmux.send_keys 'C-r'
|
||||||
tmux.until { |lines| assert_includes lines[-2], '+T*' }
|
tmux.until { |lines| assert_includes lines[-2], '+T*' }
|
||||||
|
|
||||||
@@ -1769,7 +1769,7 @@ class TestCore < TestInteractive
|
|||||||
assert_includes lines, '> 1'
|
assert_includes lines, '> 1'
|
||||||
end
|
end
|
||||||
|
|
||||||
# Trigger reload — blocked during initial sleep
|
# Trigger reload - blocked during initial sleep
|
||||||
tmux.send_keys 'C-r'
|
tmux.send_keys 'C-r'
|
||||||
tmux.until { |lines| assert_includes lines[-2], '+T*' }
|
tmux.until { |lines| assert_includes lines[-2], '+T*' }
|
||||||
# Match "1" arrives, unblocks before the remaining items load
|
# Match "1" arrives, unblocks before the remaining items load
|
||||||
@@ -1790,7 +1790,7 @@ class TestCore < TestInteractive
|
|||||||
assert_includes lines, '> 1'
|
assert_includes lines, '> 1'
|
||||||
end
|
end
|
||||||
|
|
||||||
# Trigger reload-sync — every observable state must be either:
|
# Trigger reload-sync - every observable state must be either:
|
||||||
# 1. +T* (still blocked), or
|
# 1. +T* (still blocked), or
|
||||||
# 2. final state (count=10, +T without *)
|
# 2. final state (count=10, +T without *)
|
||||||
# Any other combination (e.g. unblocked while count < 10) is a bug.
|
# Any other combination (e.g. unblocked while count < 10) is a bug.
|
||||||
@@ -1835,7 +1835,7 @@ class TestCore < TestInteractive
|
|||||||
tmux.send_keys :Up
|
tmux.send_keys :Up
|
||||||
tmux.until { |lines| assert_includes lines, '> beta' }
|
tmux.until { |lines| assert_includes lines, '> beta' }
|
||||||
|
|
||||||
# Reload with completely different items — no match for "beta"
|
# Reload with completely different items - no match for "beta"
|
||||||
tmux.send_keys 'C-r'
|
tmux.send_keys 'C-r'
|
||||||
tmux.until { |lines| assert_includes lines[-2], '+T*' }
|
tmux.until { |lines| assert_includes lines[-2], '+T*' }
|
||||||
# After stream completes, unblocks with cursor at same position (second item)
|
# After stream completes, unblocks with cursor at same position (second item)
|
||||||
@@ -1857,7 +1857,7 @@ class TestCore < TestInteractive
|
|||||||
tmux.send_keys 'C-t'
|
tmux.send_keys 'C-t'
|
||||||
tmux.until { |lines| assert_includes lines[-2], '+t' }
|
tmux.until { |lines| assert_includes lines[-2], '+t' }
|
||||||
|
|
||||||
# Reload — should track by field "2"
|
# Reload - should track by field "2"
|
||||||
tmux.send_keys 'C-r'
|
tmux.send_keys 'C-r'
|
||||||
tmux.until do |lines|
|
tmux.until do |lines|
|
||||||
assert_equal 3, lines.match_count
|
assert_equal 3, lines.match_count
|
||||||
@@ -1876,7 +1876,7 @@ class TestCore < TestInteractive
|
|||||||
tmux.send_keys :Up, :Up, :Tab
|
tmux.send_keys :Up, :Up, :Tab
|
||||||
tmux.until { |lines| assert_includes lines[-2], '(2)' }
|
tmux.until { |lines| assert_includes lines[-2], '(2)' }
|
||||||
|
|
||||||
# Reload — selections should be preserved by id-nth key
|
# Reload - selections should be preserved by id-nth key
|
||||||
tmux.send_keys 'C-r'
|
tmux.send_keys 'C-r'
|
||||||
tmux.until do |lines|
|
tmux.until do |lines|
|
||||||
assert_equal 3, lines.match_count
|
assert_equal 3, lines.match_count
|
||||||
|
|||||||
+1
-1
@@ -40,7 +40,7 @@ class TestServer < TestInteractive
|
|||||||
assert_equal [0, 1], state[:current][:positions]
|
assert_equal [0, 1], state[:current][:positions]
|
||||||
assert_equal state[:current][:positions], state[:current][:positions].sort
|
assert_equal state[:current][:positions], state[:current][:positions].sort
|
||||||
|
|
||||||
# No match — no current item
|
# 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