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

calva evaluate current file - surprise #2554

Open
Gnurdle opened this issue May 18, 2024 · 1 comment
Open

calva evaluate current file - surprise #2554

Gnurdle opened this issue May 18, 2024 · 1 comment

Comments

@Gnurdle
Copy link
Contributor

Gnurdle commented May 18, 2024

Greetings,

Peter, I had brought this up earlier, but never had a decent repro, but stumbled back into this again.

The issue is that this evaluate actually evaluates the current copy on disk, not what is in the buffer (at least for cljs).

Mentally this maps in my mind to the emacs/cider "evaluate buffer", which actually stuffs the current buffer through the repl
and evaluates it.

Thus, if I do this command, but forget to save the buffer first, surprises lurk.

It's probably not that big of a deal, but making changes, evaluating buffer without saving, and have them applied in the repl is a (albiet sloppy) workflow that I had gotten used to in cider.

There is nothing really wrong with evaluating the file on disk, but if the current buffer is dirty then then might be a surprise - and a prompt to save the file first might be in order.

Guess it hinges on what your definition of "current file" is.

C

@PEZ
Copy link
Collaborator

PEZ commented May 19, 2024

Hi! Calva uses the load-file nrepl op for doing this. The behavior you note is tied to that. I was under the impression that cider-load-buffer did the same. Though it auto-saves the buffer first. Calva doesn't, but it's easy to bind the runCommands command to a sequence that first saves the file and then loads it.

Personally I seldom load the entire file. It's mostly only when starting a session. After that I evaluate forms. And then what's in the editor is what counts, rather than what's on file.

It's also pretty easy to use runCommands to give yourself an evaluate buffer command that works more like what you describe.

  {
    "command": "runCommands",
    "key": "ctrl+alt+c ctrl+alt+enter",
    "args": {
      "commands": [
        "editor.action.selectAll",
        "calva.evaluateSelection",
        "cursorUndo"
      ]
    }
  },

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

No branches or pull requests

2 participants