Skip to content

feat: add terminal_command to the completion context #2001

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 22, 2025

Conversation

friedow
Copy link
Contributor

@friedow friedow commented Jul 18, 2025

This extends the completion context with the terminal_command in terminal buffers as requested in #1747. The terminal_command will contain all text starting from the end of the shell prompt to the current cursor position.

Example:
If you type "ls --he" into a terminal buffer in neovim the current line will look something like this:

~/Downloads > ls --a| --long
"~/Downloads > " is your prompt <- an extmark is added after this
"ls --a" is the command you typed until your cursor <- this is what will be in `terminal_command`
"|" marks your cursor position
" --long" is dropped because it is after your current cursor position

One caveat of this implementation is that it does not support multiline terminal commands. In multiline commands it will always provide you with the content of the last line. This is because there is no way to distinguish the starting point of a single line command from a multiline one using terminal escape sequences. 🤷

@Saghen
Copy link
Owner

Saghen commented Jul 21, 2025

I've added whether the escape code was found as well as the start column of the prompt. Wdyt?

@friedow
Copy link
Contributor Author

friedow commented Jul 22, 2025

That looks good and gives way more information than my initial implementation :). Thanks @Saghen

@Saghen Saghen merged commit b163deb into Saghen:main Jul 22, 2025
4 checks passed
@Saghen
Copy link
Owner

Saghen commented Jul 22, 2025

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants