8000 Add `commandline --showing-suggestion` by mqudsi · Pull Request #10586 · fish-shell/fish-shell · GitHub
[go: up one dir, main page]

Skip to content

Add commandline --showing-suggestion#10586

Merged
mqudsi merged 3 commits intofish-shell:masterfrom
mqudsi:commandline-showing-suggestion
Jul 8, 2024
Merged

Add commandline --showing-suggestion#10586
mqudsi merged 3 commits intofish-shell:masterfrom
mqudsi:commandline-showing-suggestion

Conversation

@mqudsi
Copy link
Contributor
@mqudsi mqudsi commented Jun 24, 2024

Returns 0 (true) in case an autosuggestion is currently being displayed.

This was first requested in #5000 then again in #10580 after the existing workaround for this missing functionality was broken as part of a change to the overall behavior of commandline (for the better).

I haven't written the documentation or put in much work besides adding it and checking it more or less works as I would like to see if anyone has any objections to this.

@mqudsi
Copy link
Contributor Author
mqudsi commented Jun 27, 2024

Added unit tests and documentation.

@mqudsi mqudsi force-pushed the commandline-showing-suggestion branch 6 times, most recently from e512820 to 51f6a8d Compare June 27, 2024 04:52
@mqudsi mqudsi added this to the fish next-3.x milestone Jun 27, 2024
@mqudsi mqudsi force-pushed the commandline-showing-suggestion branch from 51f6a8d to 443514e Compare June 27, 2024 23:43
src/reader.rs Outdated
// never called in a stock fish installation, and expected to generally never end up
// actually calling yield_now() except under CI or on really slow machines.)
while reader.autosuggestion.is_empty() && !reader.in_flight_autosuggest_request.is_empty() {
std::thread::yield_now();
Copy link
Member

Choose a reason for hiding this comment

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

This won't have the intended effect - autosuggestions are determined in the background and are applied via a callback (see autosuggest_completed). Simply yielding to the scheduler won't cause this to run.

I suggest simply removing this unless something breaks without it, in which case we'll have to understand why.

Copy link
Contributor Author
@mqudsi mqudsi Jun 30, 2024

Choose a reason for hiding this comment

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

The competition runs on the same thread? Because CI is broken without this loop.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, the completion runs on the same thread - aka the "main" thread.

The CI passed for me without this loop. Indeed if the loop were ever entered, it would be an infinite, hang which I was able to reproduce with some testing.

CI failures here are probably the normal runners-are-slow stuff which can be addressed by increasing the sleep in the tests.

Please remove this bit and up the sleep if necessary. Otherwise this looks good.

Copy link
Contributor Author
@mqudsi mqudsi Jul 8, 2024

Choose a reason for hiding this comment

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

Thanks for checking it again. I can confirm it's passing now on the regular runs.

I don’t think adding sleeps helps. Those are for the active highlight thread for the tty/prompt but we start this reader and return a response immediately regardless of how long that sleep was.

Copy link
Member
@ridiculousfish ridiculousfish left a comment

Choose a reason for hiding this comment

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

I like the new feature but the thread::yield looks wrong to me.

mqudsi added 3 commits July 7, 2024 22:27
Returns 0 (true) in case an autosuggestion is currently being displayed.

This was first requested in fish-shell#5000 then again in fish-shell#10580 after the existing
workaround for this missing functionality was broken as part of a change to the
overall behavior of `commandline` (for the better).
@mqudsi mqudsi force-pushed the commandline-showing-suggestion branch from 443514e to a59dcf5 Compare July 8, 2024 03:28
@mqudsi mqudsi merged commit 936f7d9 into fish-shell:master Jul 8, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 14, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Is possible to detect if an auto-suggestion is being displayed?

2 participants

0