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

Add basic REPL History search #2540

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

Conversation

mrkam2
Copy link
Contributor

@mrkam2 mrkam2 commented Apr 27, 2024

What has changed?

This implements a very basic REPL History search.

Fixes #2175

My Calva PR Checklist

I have:

  • Read How to Contribute.
  • Directed this pull request at the dev branch. (Or have specific reasons to target some other branch.)
  • Made sure I have changed the PR base branch, so that it is not published. (Sorry for the nagging.)
  • Made sure there is an issue registered with a clear problem statement that this PR addresses, (created the issue if it was not present).
    • Updated the [Unreleased] entry in CHANGELOG.md, linking the issue(s) that the PR is addressing.
  • Figured if anything about the fix warrants tests on Mac/Linux/Windows/Remote/Whatever, and either tested it there if so, or mentioned it in the PR.
  • Added to or updated docs in this branch, if appropriate
  • Tests
    • Tested the particular change
    • Figured if the change might have some side effects and tested those as well.
  • Formatted all JavaScript and TypeScript code that was changed. (use the prettier extension or run npm run prettier-format)
  • Confirmed that there are no linter warnings or errors (use the eslint extension, run npm run eslint before creating your PR, or run npm run eslint-watch to eslint as you go).

Ping @PEZ, @bpringe, @corasaurus-hex, @Cyrik

Copy link

netlify bot commented Apr 27, 2024

Deploy Preview for calva-docs ready!

Name Link
🔨 Latest commit fcf8060
🔍 Latest deploy log https://app.netlify.com/sites/calva-docs/deploys/662c4205e3a4510008729c8d
😎 Deploy Preview https://deploy-preview-2540--calva-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

function searchReplHistory(): void {
const editor = util.getActiveTextEditor();
const history = getHistory(getSessionType());
vscode.window.showInputBox({
Copy link
Collaborator

Choose a reason for hiding this comment

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

It may be this dangling promise that causes the linter to complain. I think the solution is to return the promise, because otherwise systems like Joyride and runCommands can't wait for the command to finish, which limits its usefulness.

Suggested change
vscode.window.showInputBox({
return vscode.window.showInputBox({

Copy link
Collaborator

@PEZ PEZ left a comment

Choose a reason for hiding this comment

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

Hi! Thanks for helping improve Calva! 🙏

Before we will consider merge, you'll need to reinstall the checklist of the PR and tick items off as you have completed them. Don't hesitate to ask us for help if there's anything that is unclear or you just want help with it for whatever reason.

@mrkam2
Copy link
Contributor Author

mrkam2 commented Apr 29, 2024

This implementation is very basic. It is missing a few things:

  • iterating over several results having the same match,
  • highlighting the match.

I'm curious how you would've implemented these. ChatGPT suggests to use a custom view. Maybe that's what I'll try next. But so far I've compiled the version of the plugin to test with and want to see how much those issues would affect me.

@PEZ
Copy link
Collaborator

PEZ commented Apr 30, 2024

I'm curious how you would've implemented these. ChatGPT suggests to use a custom view.

It's important that this is kept simple and low maintenance. I don't think anyone in the Calva team really uses the REPL Window much and we're not keen on building it out much more. I think that eventually we may replace it by something simpler alltogether.

I think I would try with a quickpick menu first. Building it from the full repl history. That would offload the search and match to VS Code. Joyride example:

(vscode/window.showQuickPick
 #js [#js {:label "(when-let [requires (resolve 'clojure.main/repl-requires)]\n(clojure.core/apply clojure.core/require @requires))"
           :detail "[clj] user"}
      #js {:label "(println 42)"
           :detail "[cljs] pez.pirate-lang"}])

This pops open a quickpick menu with the two items, showing the start of both. When the user types, any matching text will be highlighted in the menu and the menu will shrink to only the matchin items. It has limitations. Only the start of the text is shown, and if the match is outside the visible text, it will be invisible. But the menu will still shrink to only the matching items, so I think it is good enough and worth to try.

@mrkam2
Copy link
Contributor Author

mrkam2 commented Apr 30, 2024

I don't think anyone in the Calva team really uses the REPL Window much

Interesting. Do you refer to all Calva users or just some core members?

@PEZ
Copy link
Collaborator

PEZ commented Apr 30, 2024

I don't think anyone in the Calva team really uses the REPL Window much

Interesting. Do you refer to all Calva users or just some core members?

I'm referring to the maintainers of Calva.

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.

None yet

2 participants