[GH-ISSUE #554] Feature request: Configurable autocompleteselect in inputfield #403

Closed
opened 2026-03-04 01:04:40 +03:00 by kerem · 4 comments
Owner

Originally created by @rmasp98 on GitHub (Jan 20, 2021).
Original GitHub issue: https://github.com/rivo/tview/issues/554

Hi,

Firstly, thank you for such a great library!

I was wondering if you would be open to a configurable autocompleteselect function in the inputfield primitive. This would allow for more sophisticated autocomplete functionality without much complexity, which would be helpful for my app because the search bar I am writing accepts quite complex queries, so I would prefer the autocomplete function to only alter parts of the query rather than the entire text.

This is fairly simple to create (with just a member, setter and getter, and a check in the InputHandler) and I have tested it in my app and it seems to run fine. I would be happy to create a pull request for this.

If you wanted to check out what I am trying to achieve, you can see my app here. It is currently written using go-cui but I am in the middle of rewriting it with tview.

Originally created by @rmasp98 on GitHub (Jan 20, 2021). Original GitHub issue: https://github.com/rivo/tview/issues/554 Hi, Firstly, thank you for such a great library! I was wondering if you would be open to a configurable autocompleteselect function in the inputfield primitive. This would allow for more sophisticated autocomplete functionality without much complexity, which would be helpful for my app because the search bar I am writing accepts quite complex queries, so I would prefer the autocomplete function to only alter parts of the query rather than the entire text. This is fairly simple to create (with just a member, setter and getter, and a check in the InputHandler) and I have tested it in my app and it seems to run fine. I would be happy to create a pull request for this. If you wanted to check out what I am trying to achieve, you can see my app [here](https://github.com/rmasp98/kube-review). It is currently written using go-cui but I am in the middle of rewriting it with tview.
kerem closed this issue 2026-03-04 01:04:41 +03:00
Author
Owner

@rivo commented on GitHub (Feb 17, 2021):

I suppose you could use SetChangedFunc() to listen to changes to the input field (including the ones made via autocomplete) and then setting its text to the full string again. You'd just have to be careful not to create an infinite loop. What do you think about that?

<!-- gh-comment-id:780415380 --> @rivo commented on GitHub (Feb 17, 2021): I suppose you could use [`SetChangedFunc()`](https://pkg.go.dev/github.com/rivo/tview#InputField.SetChangedFunc) to listen to changes to the input field (including the ones made via autocomplete) and then setting its text to the full string again. You'd just have to be careful not to create an infinite loop. What do you think about that?
Author
Owner

@rmasp98 commented on GitHub (Mar 4, 2021):

How would I do that?

The only way I can think of is to store the old field text and cursor position in global variables and then capture a reference to the input field in the changed function (so that I can update the text) but like you said, whenever I set text, it will trigger an infinite loop. So would I have to unset the changed function, set the text and then re-set the changed function?

This approach feels really messy, so would be open to a better approach.

Is the original suggestion out of the question?

<!-- gh-comment-id:790491410 --> @rmasp98 commented on GitHub (Mar 4, 2021): How would I do that? The only way I can think of is to store the old field text and cursor position in global variables and then capture a reference to the input field in the `changed` function (so that I can update the text) but like you said, whenever I set text, it will trigger an infinite loop. So would I have to unset the changed function, set the text and then re-set the changed function? This approach feels really messy, so would be open to a better approach. Is the original suggestion out of the question?
Author
Owner

@rivo commented on GitHub (Jun 24, 2021):

Can you make a suggestion for an actual configurable autocompleteselect function, i.e. what would such a function look like which would satisfy your requirements? I'm not quite sure what information you need to determine partial queries and how you would replace the selection in the input. (It sounded like you have an implementation already so it would be good to see how you solved this.)

<!-- gh-comment-id:867911045 --> @rivo commented on GitHub (Jun 24, 2021): Can you make a suggestion for an actual configurable autocompleteselect function, i.e. what would such a function look like which would satisfy your requirements? I'm not quite sure what information you need to determine partial queries and how you would replace the selection in the input. (It sounded like you have an implementation already so it would be good to see how you solved this.)
Author
Owner

@rivo commented on GitHub (Nov 9, 2021):

Any interest in this still?

<!-- gh-comment-id:964272356 --> @rivo commented on GitHub (Nov 9, 2021): Any interest in this still?
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/tview#403
No description provided.