tomrijndorp / vscode-finditfaster

Find it, but faster! Fast file search for VS Code.
MIT License
280 stars 29 forks source link

Search for files works fine but Search Text Within Files crashes #106

Open shivanshPurple opened 2 months ago

shivanshPurple commented 2 months ago
/home/user/.vscode/extensions/tomrijndorp.find-it-faster-0.0.38/find_within_files.sh  '/home/user/DCA-DMAP'
/home/user/.vscode/extensions/tomrijndorp.find-it-faster-0.0.38/find_within_files.sh  '/home/user/DCA-DMAP'
/home/user/.vscode/extensions/tomrijndorp.find-it-faster-0.0.38/find_within_files.sh: line 4: EXTENSION_PATH: unbound variable

This error occurs if I go for Search Text Within Files.

But this doesn't happen if I do search for files. Search for files works fine.

gojanpaolo commented 2 weeks ago

Mine also crashes. But I only see this on my terminal

::: Terminal allocated for FindItFaster. Do not use. ::: 

image

I'm on WSL Ubuntu

@shivanshPurple how did you get those logs?

gojanpaolo commented 2 weeks ago

Ah got it. You ran the .sh directly. I was able to reproduce the same error

$ /home/foo/.vscode-server/extensions/tomrijndorp.find-it-faster-0.0.39/find_within_files.sh 'home/foo'
/home/foo/.vscode-server/extensions/tomrijndorp.find-it-faster-0.0.39/find_within_files.sh: line 4: EXTENSION_PATH: unbound variable
gojanpaolo commented 2 weeks ago

But it looks like that is incorrect way of reproducing the issue because I also get the same error when running find_files.sh directly

$ /home/foo/.vscode-server/extensions/tomrijndorp.find-it-faster-0.0.39/find_files.sh 'home/foo'
/home/foo/.vscode-server/extensions/tomrijndorp.find-it-faster-0.0.39/find_files.sh: line 4: EXTENSION_PATH: unbound variable
gojanpaolo commented 2 weeks ago

I think this is the actual error

unsupported key: backward-eof

Full logs

+ . /home/jan/.vscode-server/extensions/tomrijndorp.find-it-faster-0.0.39/shared.sh
++ USE_GITIGNORE_OPT=()
++ [[ 1 -eq 0 ]]
++ IFS=:
++ read -r -a TYPE_FILTER
++ TYPE_FILTER_ARR=()
++ IFS=:
++ read -r -a GLOB_PATTERNS
++ GLOBS=()
++ for ENTRY in ${GLOB_PATTERNS[@]+"${GLOB_PATTERNS[@]}"}
++ GLOBS+=("--glob")
++ GLOBS+=("$ENTRY")
++ for ENTRY in ${GLOB_PATTERNS[@]+"${GLOB_PATTERNS[@]}"}
++ GLOBS+=("--glob")
++ GLOBS+=("$ENTRY")
++ for ENTRY in ${GLOB_PATTERNS[@]+"${GLOB_PATTERNS[@]}"}
++ GLOBS+=("--glob")
++ GLOBS+=("$ENTRY")
+++ fzf --version
++ FZF_VER=0.20.0
+++ echo 0.20.0
+++ awk '{print $1}'
++ FZF_VER_NUM=0.20.0
++ FZF_VER_PT1=0.2
++ FZF_VER_PT2=0
+ PATHS=("$@")
+ SINGLE_DIR_ROOT=
+ '[' 1 -eq 1 ']'
+ SINGLE_DIR_ROOT=/home/jan
+ PATHS=()
+ cd /home/jan
+ RG_PREFIX=(rg --column --hidden $(array_join ${USE_GITIGNORE_OPT+"${USE_GITIGNORE_OPT[@]}"}) --line-number --no-heading --color=always --smart-case --colors 'match:fg:green' --colors 'path:fg:white' --colors 'path:style:nobold' --glob "'!**/.git/'" $(array_join "${GLOBS[@]+"${GLOBS[@]}"}"))
++ array_join
++ [[ 0 -gt 0 ]]
++ array_join --glob '!**/node_modules' --glob '!**/bower_components' --glob '!**/*.code-search'
++ [[ 6 -gt 0 ]]
++ for arg in "$@"
++ printf ''\''%s'\'' ' --glob
++ for arg in "$@"
++ printf ''\''%s'\'' ' '!**/node_modules'
++ for arg in "$@"
++ printf ''\''%s'\'' ' --glob
++ for arg in "$@"
++ printf ''\''%s'\'' ' '!**/bower_components'
++ for arg in "$@"
++ printf ''\''%s'\'' ' --glob
++ for arg in "$@"
++ printf ''\''%s'\'' ' '!**/*.code-search'
+ [[ 0 -gt 0 ]]
+ RG_PREFIX+=(" 2> /dev/null")
+ PREVIEW_ENABLED=1
+ PREVIEW_COMMAND='bat --decorations=always --color=always {1} --highlight-line {2} --style=header,grid'
+ PREVIEW_WINDOW='right:border-left:50%:+{2}+3/3:~3'
+ HAS_SELECTION=
+ RESUME_SEARCH=
+ FUZZ_RG_QUERY=0
+ QUERY='^'
+ INITIAL_QUERY=
+ INITIAL_POS=1
+ [[ '' -eq 1 ]]
+ [[ '' -eq 1 ]]
+ [[ 0.2 == \0\.\2 ]]
+ [[ 0 -lt 7 ]]
+ [[ bat --decorations=always --color=always {1} --highlight-line {2} --style=header,grid != '' ]]
+ PREVIEW_COMMAND='bat {1} --color=always --highlight-line {2} --line-range {2}:'
+ [[ right:border-left:50%:+{2}+3/3:~3 != '' ]]
+ PREVIEW_WINDOW=right:50%
+ PREVIEW_STR=()
+ [[ 1 -eq 1 ]]
+ PREVIEW_STR=(--preview "$PREVIEW_COMMAND" --preview-window "$PREVIEW_WINDOW")
+ RESUME_POS_BINDING=backward-eof:ignore
++ printf '%s\n' 0.20.0 0.36
++ head -n 1
++ sort -V
+ [[ 0.20.0 == \0\.\3\6 ]]
+ RG_QUERY_PARSING='{q}'
+ [[ 0 -eq 1 ]]
++ array_join rg --column --hidden --line-number --no-heading --color=always --smart-case --colors match:fg:green --colors path:fg:white --colors path:style:nobold --glob ''\''!**/.git/'\''' ''\''--glob'\''' ''\''!**/node_modules'\''' ''\''--glob'\''' ''\''!**/bower_components'\''' ''\''--glob'\''' ''\''!**/*.code-search'\''' ' 2> /dev/null'
++ [[ 22 -gt 0 ]]
++ for arg in "$@"
++ printf ''\''%s'\'' ' rg
++ for arg in "$@"
++ printf ''\''%s'\'' ' --column
++ for arg in "$@"
++ printf ''\''%s'\'' ' --hidden
++ for arg in "$@"
++ printf ''\''%s'\'' ' --line-number
++ for arg in "$@"
++ printf ''\''%s'\'' ' --no-heading
++ for arg in "$@"
++ printf ''\''%s'\'' ' --color=always
++ for arg in "$@"
++ printf ''\''%s'\'' ' --smart-case
++ for arg in "$@"
++ printf ''\''%s'\'' ' --colors
++ for arg in "$@"
++ printf ''\''%s'\'' ' match:fg:green
++ for arg in "$@"
++ printf ''\''%s'\'' ' --colors
++ for arg in "$@"
++ printf ''\''%s'\'' ' path:fg:white
++ for arg in "$@"
++ printf ''\''%s'\'' ' --colors
++ for arg in "$@"
++ printf ''\''%s'\'' ' path:style:nobold
++ for arg in "$@"
++ printf ''\''%s'\'' ' --glob
++ for arg in "$@"
++ printf ''\''%s'\'' ' ''\''!**/.git/'\'''
++ for arg in "$@"
++ printf ''\''%s'\'' ' ''\''--glob'\'''
++ for arg in "$@"
++ printf ''\''%s'\'' ' ''\''!**/node_modules'\'''
++ for arg in "$@"
++ printf ''\''%s'\'' ' ''\''--glob'\'''
++ for arg in "$@"
++ printf ''\''%s'\'' ' ''\''!**/bower_components'\'''
++ for arg in "$@"
++ printf ''\''%s'\'' ' ''\''--glob'\'''
++ for arg in "$@"
++ printf ''\''%s'\'' ' ''\''!**/*.code-search'\'''
++ for arg in "$@"
++ printf ''\''%s'\'' ' ' 2> /dev/null'
+ RG_PREFIX_STR=''\''rg'\'' '\''--column'\'' '\''--hidden'\'' '\''--line-number'\'' '\''--no-heading'\'' '\''--color=always'\'' '\''--smart-case'\'' '\''--colors'\'' '\''match:fg:green'\'' '\''--colors'\'' '\''path:fg:white'\'' '\''--colors'\'' '\''path:style:nobold'\'' '\''--glob'\'' '\'''\''!**/.git/'\'''\'' '\'''\''--glob'\'''\'' '\'''\''!**/node_modules'\'''\'' '\'''\''--glob'\'''\'' '\'''\''!**/bower_components'\'''\'' '\'''\''--glob'\'''\'' '\'''\''!**/*.code-search'\'''\'' '\'' 2> /dev/null'\'' '
+ RG_PREFIX_STR='rg --column --hidden --line-number --no-heading --color=always --smart-case --colors match:fg:green --colors path:fg:white --colors path:style:nobold --glob '\''!**/.git/'\'' '\''--glob'\'' '\''!**/node_modules'\'' '\''--glob'\'' '\''!**/bower_components'\'' '\''--glob'\'' '\''!**/*.code-search'\''  2> /dev/null'
++ array_join
++ [[ 0 -gt 0 ]]
+ FZF_CMD='rg --column --hidden --line-number --no-heading --color=always --smart-case --colors match:fg:green --colors path:fg:white --colors path:style:nobold --glob '\''!**/.git/'\'' '\''--glob'\'' '\''!**/node_modules'\'' '\''--glob'\'' '\''!**/bower_components'\'' '\''--glob'\'' '\''!**/*.code-search'\''  2> /dev/null '\''^'\'' '
+ echo 'rg --column --hidden --line-number --no-heading --color=always --smart-case --colors match:fg:green --colors path:fg:white --colors path:style:nobold --glob '\''!**/.git/'\'' '\''--glob'\'' '\''!**/node_modules'\'' '\''--glob'\'' '\''!**/bower_components'\'' '\''--glob'\'' '\''!**/*.code-search'\''  2> /dev/null'
rg --column --hidden --line-number --no-heading --color=always --smart-case --colors match:fg:green --colors path:fg:white --colors path:style:nobold --glob '!**/.git/' '--glob' '!**/node_modules' '--glob' '!**/bower_components' '--glob' '!**/*.code-search'  2> /dev/null
+ IFS=:
+ read -ra VAL
+++ array_join
+++ [[ 0 -gt 0 ]]
++ FZF_DEFAULT_COMMAND='rg --column --hidden --line-number --no-heading --color=always --smart-case --colors match:fg:green --colors path:fg:white --colors path:style:nobold --glob '\''!**/.git/'\'' '\''--glob'\'' '\''!**/node_modules'\'' '\''--glob'\'' '\''!**/bower_components'\'' '\''--glob'\'' '\''!**/*.code-search'\''  2> /dev/null '\''^'\'' '
++ fzf --ansi --cycle --bind 'change:reload:sleep 0.1; rg --column --hidden --line-number --no-heading --color=always --smart-case --colors match:fg:green --colors path:fg:white --colors path:style:nobold --glob '\''!**/.git/'\'' '\''--glob'\'' '\''!**/node_modules'\'' '\''--glob'\'' '\''!**/bower_components'\'' '\''--glob'\'' '\''!**/*.code-search'\''  2> /dev/null {q}  || true' --delimiter : --history /tmp/find-it-faster-fThMcr/last_query --bind 'enter:execute(echo {n} > /tmp/find-it-faster-fThMcr/last_position)+accept' --bind backward-eof:ignore --phony --query '' --preview 'bat {1} --color=always --highlight-line {2} --line-range {2}:' --preview-window right:50%
unsupported key: backward-eof
+ [[ 0 -eq 0 ]]
+ echo canceled
canceled
+ echo 1
+ exit 1
gojanpaolo commented 2 weeks ago

Could be related here? https://github.com/tomrijndorp/vscode-finditfaster/pull/46#discussion_r1335081087

shivanshPurple commented 2 weeks ago

Hey. Yeah I also dont properly remember how was I able to reproduce this. But I think I was able to run the commands via 'open terminal in editor' option. But yeah, I still dont have any solutions.

gojanpaolo commented 2 weeks ago

https://github.com/tomrijndorp/vscode-finditfaster/blob/main/find_within_files.sh#L80-L82

# dummy fallback binding because fzf v<0.36 does not support `load` and I did not figure out how to
# conditionally set the entire binding string (i.e., with the "--bind" part)
RESUME_POS_BINDING="backward-eof:ignore"

I'm on fzf --version 0.20.0 and my lsb_release -a is Ubuntu 20.04.3 LTS. I'll try upgrading to Ubuntu 24.04 then upgrade fzf to 0.44.1. 🤞

gojanpaolo commented 2 weeks ago

search within files works after upgrading! 🎉

$ fzf --version
0.44.1 (debian)

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 24.04.1 LTS
Release:        24.04
Codename:       noble
shivanshPurple commented 2 weeks ago

Good for you, unfortunately I cant upgrade as I was using it on a company laptop

gojanpaolo commented 2 weeks ago

@shivanshPurple I think we'll be able to solve the issue (and create a PR in this extension 😊). 1 Let's start with, what fzf version or OS version are you on? Can you upgrade to at least fzf 0.22 (e.g. if you're on at least ubuntu 22.04?