chrisant996 / clink

Bash's powerful command line editing in cmd.exe
https://chrisant996.github.io/clink/
GNU General Public License v3.0
3.44k stars 135 forks source link

TAB complete going wrong #637

Closed craciu25yt closed 1 month ago

craciu25yt commented 1 month ago

when I'm in C:\Users\craciu25yt (me) and I do cd desk it shows at the tab completion desktop\ but when I press it it somehow completes .designer\. It will only work if I use the right arrow key

chrisant996 commented 1 month ago

That's not "completion". That's "auto suggestions".

See here in the docs.

craciu25yt commented 1 month ago

ahh, I see. And there's a way to sync this two?

chrisant996 commented 1 month ago

ahh, I see. And there's a way to sync this two?

I'm not sure I understand what "sync this two" means.

Do you mean you don't want the auto-suggestions feature, and instead you want to see a preview of what "completion" would do?

That's not possible to build, even, for several reasons. At a minimum it would result in unavoidable random hangs while you type. The only way to avoid the hangs would be to make it not be an exact preview, which would ruin the whole point of the request.

But it's a completely different feature from completions. If you don't like it, turn it off -- that's totally ok to do!

craciu25yt commented 1 month ago

No. I mean like when there's an empty argument (basically that the last character is a space) and you click tab it loops through all the files but when you type something and autosuggestion shows up tab completes the suggestion. So I mean like disabling completion if there's a autosuggestion. Sorry if I explained myself wrongly

craciu25yt commented 1 month ago

I don't know if you had played minecraft but basically make tab work like it

chrisant996 commented 1 month ago

If you want to try that, here is a script that does it. Save the sample code below into a file such as "issue637.lua" in your profile directory. (Run clink info to find your profile directory.)

issue637.lua

function issue637_tab(rl_buffer)
    if rl_buffer:hassuggestion() then
        rl.invokecommand("clink-insert-suggested-line")
    else
        rl.invokecommand("old-menu-complete")
    end
end

rl.setbinding([["\t"]], [["luafunc:issue637_tab"]])

rl.describemacro([["luafunc:issue637_tab"]], "Insert the suggested line, if any, otherwise cycle through completions")

But I don't think that's going to actually be very useful or desirable. It almost completely breaks completions, most of the time. But maybe you'll really like that behavior, I don't know.

The auto-suggestions feature in the fish shell and Clink represents a large amount of time investment into detailed design and analysis. There's a lot of nuanced behaviors going on that might not be obvious at first glance. If you don't like auto-suggestions, then I recommend just turning them off. Quick tiny tweaks are very unlikely to work out how one expects, and will break other more important things than what they might solve.

craciu25yt commented 1 month ago

hey. I just tested and it works how I expected. Yea I really like it this way, I see it confusing because I played a lot of hours in minecraft and the tab completion works like that and having to click the right arrow is kinda confusing for me. Also I would like to keep the autosuggestion on because if I don't have any suggestion I would like to loop through the files. Anyways, thanks for helping me