mirror of
https://github.com/junegunn/fzf.git
synced 2025-12-05 01:30:12 +00:00
Compare commits
3 Commits
91fab3b3c2
...
3f499f055e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3f499f055e | ||
|
|
1df99db0b2 | ||
|
|
535b610a6b |
6
.github/workflows/codeql-analysis.yml
vendored
6
.github/workflows/codeql-analysis.yml
vendored
@@ -33,12 +33,12 @@ jobs:
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v3
|
||||
uses: github/codeql-action/init@v4
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@v3
|
||||
uses: github/codeql-action/autobuild@v4
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v3
|
||||
uses: github/codeql-action/analyze@v4
|
||||
|
||||
16
CHANGELOG.md
16
CHANGELOG.md
@@ -3,21 +3,29 @@ CHANGELOG
|
||||
|
||||
0.67.0
|
||||
------
|
||||
- Added `--freeze-left=N` option to keep the leftmost N columns visible.
|
||||
- Added `--freeze-left=N` option to keep the leftmost N columns always visible.
|
||||
```sh
|
||||
# Keeps the file name column fixed and always visible
|
||||
# Keep the file name column fixed and always visible
|
||||
git grep --line-number --color=always -- '' |
|
||||
fzf --ansi --delimiter : --freeze-left 1
|
||||
|
||||
# Used with --keep-right
|
||||
# Can be used with --keep-right
|
||||
git grep --line-number --color=always -- '' |
|
||||
fzf --ansi --delimiter : --freeze-left 1 --keep-right
|
||||
```
|
||||
- Also added `--freeze-right=N` option to keep the rightmost N columns visible.
|
||||
- Also added `--freeze-right=N` option to keep the rightmost N columns always visible.
|
||||
```sh
|
||||
# Stronger version of --keep-right that always keeps the right-end visible
|
||||
fd | fzf --freeze-right 1
|
||||
|
||||
# Keep the base name always visible
|
||||
fd | fzf --freeze-right 1 --delimiter /
|
||||
|
||||
# Keep both leftmost and rightmost components visible
|
||||
fd | fzf --freeze-left 1 --freeze-right 1 --delimiter /
|
||||
```
|
||||
- Updated `--info=inline` to print the spinner (load indicator).
|
||||
- Bug fixes
|
||||
|
||||
0.66.1
|
||||
------
|
||||
|
||||
@@ -3546,8 +3546,9 @@ func (t *Terminal) printHighlighted(result Result, colBase tui.ColorPair, colMat
|
||||
if t.freezeLeft > 0 || t.freezeRight > 0 {
|
||||
tokens = Tokenize(item.text.ToString(), t.delimiter)
|
||||
}
|
||||
// 0 1 2| 3 |4 5
|
||||
// -----> <---
|
||||
|
||||
// 0 | 1 | 2 | 3 | 4 | 5
|
||||
// ------> <------
|
||||
if t.freezeLeft > 0 {
|
||||
if len(tokens) > 0 {
|
||||
token := tokens[util.Min(t.freezeLeft, len(tokens))-1]
|
||||
@@ -3560,7 +3561,8 @@ func (t *Terminal) printHighlighted(result Result, colBase tui.ColorPair, colMat
|
||||
splitOffset2 = 0
|
||||
} else if index >= t.freezeLeft {
|
||||
token := tokens[index]
|
||||
splitOffset2 = int(token.prefixLength) + token.text.Length()
|
||||
delimiter := strings.TrimLeftFunc(GetLastDelimiter(token.text.ToString(), t.delimiter), unicode.IsSpace)
|
||||
splitOffset2 = int(token.prefixLength) + token.text.Length() - len([]rune(delimiter))
|
||||
}
|
||||
splitOffset2 = util.Max(splitOffset2, splitOffset1)
|
||||
}
|
||||
@@ -3743,9 +3745,14 @@ func (t *Terminal) printHighlighted(result Result, colBase tui.ColorPair, colMat
|
||||
offs[idx].offset[1] -= int32(shift)
|
||||
}
|
||||
maxe -= shift
|
||||
displayWidth = t.displayWidthWithLimit(runes, 0, maxWidth)
|
||||
if !t.wrap && displayWidth > maxWidth {
|
||||
ellipsis, ellipsisWidth := util.Truncate(t.ellipsis, maxWidth/2)
|
||||
ellipsis, ellipsisWidth := util.Truncate(t.ellipsis, maxWidth)
|
||||
adjustedMaxWidth := maxWidth
|
||||
if fidx < 2 {
|
||||
// For frozen parts, reserve space for the ellipsis in the middle part
|
||||
adjustedMaxWidth -= ellipsisWidth
|
||||
}
|
||||
displayWidth = t.displayWidthWithLimit(runes, 0, adjustedMaxWidth)
|
||||
if !t.wrap && displayWidth > adjustedMaxWidth {
|
||||
maxe = util.Constrain(maxe+util.Min(maxWidth/2-ellipsisWidth, t.hscrollOff), 0, len(runes))
|
||||
transformOffsets := func(diff int32, rightTrim bool) {
|
||||
for idx, offset := range offs {
|
||||
|
||||
@@ -234,6 +234,23 @@ func StripLastDelimiter(str string, delimiter Delimiter) string {
|
||||
return strings.TrimRightFunc(str, unicode.IsSpace)
|
||||
}
|
||||
|
||||
func GetLastDelimiter(str string, delimiter Delimiter) string {
|
||||
if delimiter.str != nil {
|
||||
if strings.HasSuffix(str, *delimiter.str) {
|
||||
return *delimiter.str
|
||||
}
|
||||
} else if delimiter.regex != nil {
|
||||
locs := delimiter.regex.FindAllStringIndex(str, -1)
|
||||
if len(locs) > 0 {
|
||||
lastLoc := locs[len(locs)-1]
|
||||
if lastLoc[1] == len(str) {
|
||||
return str[lastLoc[0]:]
|
||||
}
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// JoinTokens concatenates the tokens into a single string
|
||||
func JoinTokens(tokens []Token) string {
|
||||
var output bytes.Buffer
|
||||
|
||||
@@ -1208,6 +1208,13 @@ class TestCore < TestInteractive
|
||||
tmux.until { |lines| assert_match(/^> 1 2 3XX.*XX9998 9999 10000$/,lines[-3]) }
|
||||
end
|
||||
|
||||
def test_freeze_left_and_right_delimiter
|
||||
tmux.send_keys %[seq 10000 | tr "\n" ' ' | sed 's/ / , /g' | #{FZF} --freeze-left 3 --freeze-right 3 --ellipsis XX --delimiter ' , '], :Enter
|
||||
tmux.until { |lines| assert_match(/XX, 9999 , 10000 ,$/, lines[-3]) }
|
||||
tmux.send_keys "'1000"
|
||||
tmux.until { |lines| assert_match(/^> 1 , 2 , 3 ,XX.*XX, 9999 , 10000 ,$/,lines[-3]) }
|
||||
end
|
||||
|
||||
def test_freeze_right_exceed_range
|
||||
tmux.send_keys %[seq 10000 | tr "\n" ' ' | #{FZF} --freeze-right 100000 --ellipsis XX], :Enter
|
||||
['', "'1000"].each do |query|
|
||||
|
||||
Reference in New Issue
Block a user