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: add basic command history #33

Merged
merged 1 commit into from
Oct 18, 2022

Conversation

nerg4l
Copy link
Contributor

@nerg4l nerg4l commented Oct 16, 2022

Related to #11

A really basic command history. Features:

  • On enter the history is rotated.
  • On up arrow press the user navigates in history backward (towards latest).
  • On down arrow press the user navigates in history forward (towards newest).

More complex behaviour (e.g. history suggestion with tab trigger) could be added by replacing textinput.Model of queryinput.Bubble with a fully custom model.

@noahgorstein
Copy link
Owner

noahgorstein commented Oct 16, 2022

@nerg4l thanks for your contribution! This works great for me. Just left one question but looks good to go otherwise.

@@ -90,6 +90,7 @@ func (b Bubble) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
cmd = b.writeOutputToFile()
cmds = append(cmds, cmd)
} else if b.state == state.Query {
b.queryinput.RotateHistory()
Copy link
Owner

Choose a reason for hiding this comment

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

Is this needed if we're handling the Enter message in the queryinput bubble?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately, the state changes from Query to Running in the next line, and because of that, the enter key message never reaches the queryinput.Bubble component. I did not wanted to change much. Do you have a suggestion for handling this?

Copy link
Owner

Choose a reason for hiding this comment

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

Ah, I see. This is fine for now. I think a future improvement for jqp will just be refactoring some of this state management to be able to pass messages to sub models when they are not in focus.

@noahgorstein
Copy link
Owner

Going to go ahead and merge this @nerg4l. Thanks again for your contribution! I think we'll be able to build on this by maybe showing a view of all history or something like that. And to your original comment in the PR description, I've been interested in using bubbline but just haven't had a chance to explore and implement it yet. From what I understand, there is a completion API and some other really nice features in that. Would take a bit of work to get it wired into jqp, but think it could really make it special. If you're interested in doing that or want to take a different approach, PRs are most certainly welcome :D. Cheers!

@noahgorstein noahgorstein merged commit 968696b into noahgorstein:main Oct 18, 2022
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