mirror of
https://github.com/junegunn/fzf.git
synced 2026-04-13 19:29:40 +08:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
06e70570e2 | ||
|
|
bd4a18d0a9 | ||
|
|
1b0d448c6e | ||
|
|
f584cf38f7 | ||
|
|
0eb2ae9f8b | ||
|
|
1831500018 |
24
.github/workflows/sponsors.yml
vendored
24
.github/workflows/sponsors.yml
vendored
@@ -1,24 +0,0 @@
|
|||||||
---
|
|
||||||
name: Generate Sponsors README
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
schedule:
|
|
||||||
- cron: 0 15 * * 6
|
|
||||||
jobs:
|
|
||||||
deploy:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout 🛎️
|
|
||||||
uses: actions/checkout@v5
|
|
||||||
|
|
||||||
- name: Generate Sponsors 💖
|
|
||||||
uses: JamesIves/github-sponsors-readme-action@2fd9142e765f755780202122261dc85e78459405 # v1
|
|
||||||
with:
|
|
||||||
token: ${{ secrets.SPONSORS_TOKEN }}
|
|
||||||
file: 'README.md'
|
|
||||||
|
|
||||||
- name: Deploy to GitHub Pages 🚀
|
|
||||||
uses: JamesIves/github-pages-deploy-action@d92aa235d04922e8f08b40ce78cc5442fcfbfa2f # v4
|
|
||||||
with:
|
|
||||||
branch: master
|
|
||||||
folder: '.'
|
|
||||||
2
Makefile
2
Makefile
@@ -53,6 +53,8 @@ ifeq ($(UNAME_M),x86_64)
|
|||||||
BINARY := $(BINARY64)
|
BINARY := $(BINARY64)
|
||||||
else ifeq ($(UNAME_M),amd64)
|
else ifeq ($(UNAME_M),amd64)
|
||||||
BINARY := $(BINARY64)
|
BINARY := $(BINARY64)
|
||||||
|
else ifeq ($(UNAME_M),i86pc)
|
||||||
|
BINARY := $(BINARY64)
|
||||||
else ifeq ($(UNAME_M),s390x)
|
else ifeq ($(UNAME_M),s390x)
|
||||||
BINARY := $(BINARYS390)
|
BINARY := $(BINARYS390)
|
||||||
else ifeq ($(UNAME_M),i686)
|
else ifeq ($(UNAME_M),i686)
|
||||||
|
|||||||
@@ -84,6 +84,10 @@ __fzf_history_delete() {
|
|||||||
for offset in "${offsets[@]}"; do
|
for offset in "${offsets[@]}"; do
|
||||||
builtin history -d "$offset"
|
builtin history -d "$offset"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if [[ ${#offsets[@]} -gt 0 ]] && shopt -q histappend; then
|
||||||
|
builtin history -w
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
if command -v perl > /dev/null; then
|
if command -v perl > /dev/null; then
|
||||||
|
|||||||
@@ -3516,7 +3516,9 @@ func applyPreset(opts *Options, preset string) error {
|
|||||||
opts.Preview.border = tui.BorderLine
|
opts.Preview.border = tui.BorderLine
|
||||||
opts.Preview.info = false
|
opts.Preview.info = false
|
||||||
opts.InfoStyle = infoDefault
|
opts.InfoStyle = infoDefault
|
||||||
opts.Theme.Gutter = tui.ColorAttr{Color: -1, Attr: 0}
|
opts.Theme.Gutter = tui.NewColorAttr()
|
||||||
|
space := " "
|
||||||
|
opts.Gutter = &space
|
||||||
empty := ""
|
empty := ""
|
||||||
opts.Separator = &empty
|
opts.Separator = &empty
|
||||||
opts.Scrollbar = &empty
|
opts.Scrollbar = &empty
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package fzf
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"math"
|
"math"
|
||||||
|
"slices"
|
||||||
"sort"
|
"sort"
|
||||||
"unicode"
|
"unicode"
|
||||||
|
|
||||||
@@ -30,7 +31,7 @@ type Result struct {
|
|||||||
|
|
||||||
func buildResult(item *Item, offsets []Offset, score int) Result {
|
func buildResult(item *Item, offsets []Offset, score int) Result {
|
||||||
if len(offsets) > 1 {
|
if len(offsets) > 1 {
|
||||||
sort.Sort(ByOrder(offsets))
|
slices.SortFunc(offsets, compareOffsets)
|
||||||
}
|
}
|
||||||
|
|
||||||
minBegin := math.MaxUint16
|
minBegin := math.MaxUint16
|
||||||
@@ -187,7 +188,7 @@ func (result *Result) colorOffsets(matchOffsets []Offset, nthOffsets []Offset, t
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// sort.Sort(ByOrder(offsets))
|
// slices.SortFunc(offsets, compareOffsets)
|
||||||
|
|
||||||
// Merge offsets
|
// Merge offsets
|
||||||
// ------------ ---- -- ----
|
// ------------ ---- -- ----
|
||||||
@@ -297,21 +298,20 @@ func (result *Result) colorOffsets(matchOffsets []Offset, nthOffsets []Offset, t
|
|||||||
return colors
|
return colors
|
||||||
}
|
}
|
||||||
|
|
||||||
// ByOrder is for sorting substring offsets
|
func compareOffsets(a, b Offset) int {
|
||||||
type ByOrder []Offset
|
if a[0] < b[0] {
|
||||||
|
return -1
|
||||||
func (a ByOrder) Len() int {
|
|
||||||
return len(a)
|
|
||||||
}
|
}
|
||||||
|
if a[0] > b[0] {
|
||||||
func (a ByOrder) Swap(i, j int) {
|
return 1
|
||||||
a[i], a[j] = a[j], a[i]
|
|
||||||
}
|
}
|
||||||
|
if a[1] < b[1] {
|
||||||
func (a ByOrder) Less(i, j int) bool {
|
return -1
|
||||||
ioff := a[i]
|
}
|
||||||
joff := a[j]
|
if a[1] > b[1] {
|
||||||
return (ioff[0] < joff[0]) || (ioff[0] == joff[0]) && (ioff[1] <= joff[1])
|
return 1
|
||||||
|
}
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// ByRelevance is for sorting Items
|
// ByRelevance is for sorting Items
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package fzf
|
|||||||
import (
|
import (
|
||||||
"math"
|
"math"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
|
"slices"
|
||||||
"sort"
|
"sort"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@@ -19,7 +20,7 @@ func TestOffsetSort(t *testing.T) {
|
|||||||
offsets := []Offset{
|
offsets := []Offset{
|
||||||
{3, 5}, {2, 7},
|
{3, 5}, {2, 7},
|
||||||
{1, 3}, {2, 9}}
|
{1, 3}, {2, 9}}
|
||||||
sort.Sort(ByOrder(offsets))
|
slices.SortFunc(offsets, compareOffsets)
|
||||||
|
|
||||||
if offsets[0][0] != 1 || offsets[0][1] != 3 ||
|
if offsets[0][0] != 1 || offsets[0][1] != 3 ||
|
||||||
offsets[1][0] != 2 || offsets[1][1] != 7 ||
|
offsets[1][0] != 2 || offsets[1][1] != 7 ||
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import (
|
|||||||
"os/exec"
|
"os/exec"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"slices"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -3751,7 +3752,7 @@ func (t *Terminal) printHighlighted(result Result, colBase tui.ColorPair, colMat
|
|||||||
offset := Offset{int32(p), int32(p + w)}
|
offset := Offset{int32(p), int32(p + w)}
|
||||||
charOffsets[idx] = offset
|
charOffsets[idx] = offset
|
||||||
}
|
}
|
||||||
sort.Sort(ByOrder(charOffsets))
|
slices.SortFunc(charOffsets, compareOffsets)
|
||||||
}
|
}
|
||||||
|
|
||||||
// When postTask is nil, we're printing header lines. No need to care about nth.
|
// When postTask is nil, we're printing header lines. No need to care about nth.
|
||||||
@@ -3788,7 +3789,7 @@ func (t *Terminal) printHighlighted(result Result, colBase tui.ColorPair, colMat
|
|||||||
end := start + int32(length)
|
end := start + int32(length)
|
||||||
nthOffsets[i] = Offset{int32(start), int32(end)}
|
nthOffsets[i] = Offset{int32(start), int32(end)}
|
||||||
}
|
}
|
||||||
sort.Sort(ByOrder(nthOffsets))
|
slices.SortFunc(nthOffsets, compareOffsets)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
allOffsets := result.colorOffsets(charOffsets, nthOffsets, t.theme, colBase, colMatch, t.nthAttr, nthOverlay, hidden)
|
allOffsets := result.colorOffsets(charOffsets, nthOffsets, t.theme, colBase, colMatch, t.nthAttr, nthOverlay, hidden)
|
||||||
|
|||||||
Reference in New Issue
Block a user