Skip to content
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

feat(textinput): expose UpdateSuggestions method #630

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nobe4
Copy link
Contributor

@nobe4 nobe4 commented Oct 2, 2024

This enables clients of the lib to update the suggestions at runtime whenever they please.

One direct application of this is when using m.SetValue(): After calling it, there is no way to get the updated m.CurrentSuggestion() as m.SetValue() does not update the suggestion list.

It would be possible to also run m.updateSuggestions() somewhere in m.SetValue, but that might interfere with other things.

Note

Doing the following would work, but would require some useless re-calculation.

m.SetValue("...")
m.SetSuggestions(m.AvailableSuggestions())
m.CurrentSuggestion()

See https://github.com/nobe4/gh-not/pull/188/files#diff-9a8a064fb3b750f10c2ed5e1dde89d98645d2984d15b8b541501b5f6829e32e1R25-R30 for a real-life usage.

This enables clients of the lib to update the suggestions at runtime
whenever they please.

One direct application of this is when using `m.SetValue()`:
After calling it, there is no way to get the updated
`m.CurrentSuggestion()` as `m.SetValue()` does not update the suggestion
list.

It would be possible to also run `m.updateSuggestions()` somewhere in
`m.SetValue`, but that might interfere with other things.
@nobe4 nobe4 requested a review from meowgorithm as a code owner October 2, 2024 11:18
nobe4 added a commit to nobe4/gh-not that referenced this pull request Oct 2, 2024
This prepares later work for #187. Passing parameter will enable
additional customization in the REPL and later in the config as well.

Only the `Debug` action currently uses this new parameter, to confirm
it's receiving it correctly.

Also have to do some workaround a bubble limitation, see
charmbracelet/bubbles#630
@meowgorithm
Copy link
Member

I think this make sense, though I do wonder: are they any use cases where we would not want this to be automatically called in m.SetValue() like you suggest?

@nobe4
Copy link
Contributor Author

nobe4 commented Oct 3, 2024

I don't really know if there are usecases against automatically calling it in m.SetValue().

Typically, the suggestions should be updated when:

  • the suggestions change ✅ ref
  • the value changes via keypress ✅ ref
  • the value changes via m.SetValue()

So maybe just calling it in m.SetValue() would bring it closer to the expected behavior?

In any case I'm happy for either solution :)

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