Open tex opened 11 months ago
Or ignore query until first 3 characters...
is quick response when you use raw command sg -p 'YOU PATTERN' --json=stream
?
Yes
On November 7, 2023 4:02:24 AM GMT+01:00, Marskey @.***> wrote:
is quick response when you use raw command
sg -p 'YOU PATTERN' --json=stream
?-- Reply to this email directly or view it on GitHub: https://github.com/Marskey/telescope-sg/issues/9#issuecomment-1797389356 You are receiving this because you authored the thread.
Message ID: @.***>
I think it is because a bare $
or $VAR
will match everything. The output will be stuck if telescope-sg does not kill the first large query....
This seems to be happening. In ps / top I see there is process ats-grep searching for '$', after a long time there is another process searching for '$A'....
Unfortunately, finders.new_job
does not directly support a timeout parameter. https://github.com/nvim-telescope/telescope.nvim/blob/master/lua/telescope/finders/async_job_finder.lua#L50-L58
We can have a workaround that uses the vim.defer_fn
function to achieve the desired behavior.
in telescope, when you input second 'A', it will kill last searching for '$', but I can't figure why uv.process_kill cant kill sg process
it was telescope'bug, reference to https://github.com/luvit/luv/blob/master/src/constants.c#L474 signal value should be 'sigterm' or 15 in https://github.com/nvim-telescope/telescope.nvim/blob/master/lua/telescope/_.lua#L57 I will push a patch to telescope in this week or later
The PR has been submitted in here. You can either wait for the maintainer to merge it, or you can modify it yourself
Are you delete your reply? I can’t see the message in issue
On Nov 27, 2023, at 22:21, Milan Svoboda @.***> wrote:
Well I tried the patch and it is not working (tested in Windows/WSL). Interesting is that when I close telescope dialog, the ast-grep process it killed successfully immediately.
— Reply to this email directly, view it on GitHub https://github.com/Marskey/telescope-sg/issues/9#issuecomment-1827929094, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADG74UWHA6FH5ZPWXE6XTXLYGSOW5AVCNFSM6AAAAAA67W6B4CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMRXHEZDSMBZGQ. You are receiving this because you modified the open/close state.
Yeah. I tried and I though the fix did not help. So I wrote the message. But I tried it more and found out it help, it was just slower than I expected due to probably high CPU usage... So I deleted message.
@tex I tried, there is a problem about it, I haven't a solution right now, maybe I should try another finder, I will leave it open
@Marskey I tried it today and it works correctly after this fix. Maybe it is just when the cpu is very busy that the kill takes a little more time then expected. In my opinion you can close this issue.
I noticed that sometime if you change / edit input query quickly it doesn't pick it up and no search is done. When you edit it it pick it up and does search then.
@tex @HerringtonDarkholme I found that the issue is as follows: when I input a keyword, for example, '$', Telescope spawns a process with the command sg -p '$' --json=stream
. Subsequently, Telescope suspends the coroutine, waiting for 'sg' to output results to stdout. During this period, any additional keywords entered do not terminate the process until 'sg' produces output in stdout. On the other hand, other pickers like 'live_grep' use 'rg' (ripgrep), which seems to print results while searching, avoiding this issue. Therefore, I believe either 'sg' should address this problem, or it can be disregarded altogether."
@Marskey Correct me if I am wrong. Does it mean ast-grep is not outputting anything in a large repo? To address the problem, sg should at least output something?
@Marskey Correct. ast-grep prints output after it searches all files. It may print output earlier if it finds some files it wasn't able to open or parse. Which might explain why it "works" for me because when I run it in command line it prints such warnings quite quickly.
$ sg -p '$' --json=stream
Cannot read file ./XYZ.QW
...
I think this is incorrect Telescope behavior. It might work for utilities that print something quickly, as they go, but there might be lot of other tools that just print at the end, like sg.
Thanks for the reporting! It is definitely ast-grep's bug since it should stream the results one by one instead of awaiting all results.
Weird, I can always immediately see ast-grep's output when the pattern is $
wildcard. @Marskey can you help me understand the issue here?
ast-grep 0.13.0
It is as I reported, first it prints wranings about cannot read file... Which itself is weird because I can read the file, But I am playing with tree-sitter myself (github tex ttags) and this happens when tree sitter is unable to parse it I guess. Anyway, then it prints nothing for a very long time and then I kill it manually and I guess it would print everything at once sometime at the end.
Anyway I think that Telescope needs to handle this better. It should not depend on what a given tool does.
FYI: The repo has ~120.000 files...
@HerringtonDarkholme my ast-grep version is ast-grep 0.11.1. In this version, ast-grep prints output after it searches all files when I search in the directory in which has a lot of files and subdirectories.Maybe I should upgrade my ast-grep.
@tex you'er right, I should try to report a issue to telescope or maybe I can do somthing (now i have no solution) in this plugin.
Because first search is for $ which takes lots of time. Tested in Windows/WSL. Some form of manual confirming to start searching when I entered my query would be nice.