Skip to content

cli : add command and file auto-completion#19985

Merged
CISC merged 1 commit intomasterfrom
cisc/cli-auto-completion
Mar 5, 2026
Merged

cli : add command and file auto-completion#19985
CISC merged 1 commit intomasterfrom
cisc/cli-auto-completion

Conversation

@CISC
Copy link
Member

@CISC CISC commented Feb 28, 2026

Adds auto-completion callback to console and implements command and file auto-completion in cli.

@ngxson
Copy link
Contributor

ngxson commented Mar 2, 2026

nice feature, @ServeurpersoCom could you please test this on windows? thanks!

@ServeurpersoCom
Copy link
Contributor

That's cool!

Feature request: It would be great if directory contents were automatically listed when the path reaches a separator (\ or /), similar to shell behavior.
https://github.com/user-attachments/assets/e5c1fc50-10e5-40c2-941a-9004ed0e5660

Bug: When moving the cursor back (left arrow) to a separator character and pressing Tab, the separator gets repeated across the entire line (e.g. \\\\\...).
https://github.com/user-attachments/assets/3861a0a1-6fc3-4b71-bc1c-b53163d8b718

@CISC
Copy link
Member Author

CISC commented Mar 2, 2026

Feature request: It would be great if directory contents were automatically listed when the path reaches a separator (\ or /), similar to shell behavior.

That would be the TODO.

Bug: When moving the cursor back (left arrow) to a separator character and pressing Tab, the separator gets repeated across the entire line (e.g. \\...).

Not a bug in this PR, this happens in master.

@ServeurpersoCom
Copy link
Contributor

Found this while testing, existing issue but your PR exposes it, here's a one-liner you can include:)

(root|~/llama.cpp.pascal) git diff
diff --git a/common/console.cpp b/common/console.cpp
index a770416ab..1fb278c14 100644
--- a/common/console.cpp
+++ b/common/console.cpp
@@ -995,7 +995,7 @@ namespace console {
                 }
             }

-            if (!line.empty() && (line.back() == '\\' || line.back() == '/')) {
+            if (!line.empty() && char_pos == widths.size() && (line.back() == '\\' || line.back() == '/')) {
                 replace_last(line.back());
                 is_special_char = true;
             }
(root|~/llama.cpp.pascal)

@CISC
Copy link
Member Author

CISC commented Mar 3, 2026

Found this while testing, existing issue but your PR exposes it, here's a one-liner you can include:)

Should be a separate PR, though I'm not sure what that code was supposed to do and if that's the correct fix or not?

@ServeurpersoCom
Copy link
Contributor

Found this while testing, existing issue but your PR exposes it, here's a one-liner you can include:)

Should be a separate PR, though I'm not sure what that code was supposed to do and if that's the correct fix or not?

Yes I can make short demo videos or even a PR, I tested it under Linux and Windows, it fixes the bug of the repeating character. Furthermore, I believe it was me who worked on the cursor movement with arrows keys.

@CISC
Copy link
Member Author

CISC commented Mar 3, 2026

Should be a separate PR, though I'm not sure what that code was supposed to do and if that's the correct fix or not?

Yes I can make short demo videos or even a PR, I tested it under Linux and Windows, it fixes the bug of the repeating character. Furthermore, I believe it was me who worked on the cursor movement with arrows keys.

The reason I'm saying it should be a separate PR is so that we don't hide a bugfix in an unrelated PR.

Anyway, maybe you can explain what the intention was? :) I don't understand what it's trying to do with the slashes?

@ServeurpersoCom
Copy link
Contributor

ServeurpersoCom commented Mar 3, 2026

The reason I'm saying it should be a separate PR is so that we don't hide a bugfix in an unrelated PR.
I completely agree

Anyway, maybe you can explain what the intention was? :) I don't understand what it's trying to do with the slashes?

Ah yes, it's multi-line like in bash! It works well! But I need to test it again with the PR; I completely forgot about that feature!
To try, enter :

Hello \
It's another line \
... enter

#1040

@CISC
Copy link
Member Author

CISC commented Mar 3, 2026

Anyway, maybe you can explain what the intention was? :) I don't understand what it's trying to do with the slashes?

Ah yes, it's multi-line like in bash! It works well!

Must keep that in mind if/when adding another feature PR; reading whole directories (though maybe just wildcards is more useful).

@CISC
Copy link
Member Author

CISC commented Mar 5, 2026

gentle ping for approval :)

Copy link
Member

@ggerganov ggerganov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works on Mac

@CISC CISC merged commit b5ed0e0 into master Mar 5, 2026
147 of 149 checks passed
@CISC CISC deleted the cisc/cli-auto-completion branch March 5, 2026 09:47
bartowski1182 pushed a commit to bartowski1182/llama.cpp that referenced this pull request Mar 10, 2026
Ethan-a2 pushed a commit to Ethan-a2/llama.cpp that referenced this pull request Mar 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants