vscode-tidalcycles icon indicating copy to clipboard operation
vscode-tidalcycles copied to clipboard

Eval selection

Open lopho opened this issue 6 years ago • 9 comments

Selecting multiple lines and evaluating them with shift-enter works as intended with atom tidal. On vscode it only executes the line on which the caret resides.

I'm not sure if this is intended or a bug, but it makes working with tidal in vscode more or less unfeasible for me. Or I am a bit blind and just don't get how it's supposed to work :/

Not evaluatable without executing the entire block with ~~shift-enter~~ ctrl-enter:

d1 $ s "hh*4"
  # up "0 1 2 1"

(Related to this, but not sure if a separate issue (not sure if atom handled this) are nested do blocks. Running multiline eval with ~~shift-enter~~ ctrl-enter on an nested do block executes the entire do stack, excluding the root scope.)

lopho avatar Feb 09 '19 21:02 lopho

@lopho to eval a block, you can also use Ctrl+Enter without selecting the entire block. just make sure your cursor is inside the block.

That being said, being able to make a selection and run it with shift+enter would be a good enhancement, and to make it on par with the Atom package.

kindohm avatar Feb 09 '19 21:02 kindohm

Yes, evaling a do block works with ctrl-enter (oopsie, typo in issue description), but it actually evals the surrounding do blocks as well if nested.

Evaluating the inner block, evaluates the outer as well:

do
  d1 $ s "hh*8"
  do -- can't let you eval that do block alone, mane
   d2 $ s "sd*2" 

Do I understand you correctly, that indented lines, like in the example in the issue description, should also eval with ctrl-enter (and nothing else)? If so, it does not do what it should on my machine, it evals the entire stack down to, but excluding, the root.

lopho avatar Feb 09 '19 21:02 lopho

So I deconvoluted my workspace scrapbook a bit, and tried executing indented multiline statements using ctrl-enter. It works, but only as long as they are on the root, e.g. not in another block, then the entire surrounding block stack gets evaluated.

-- evals correctly with ctrl-enter:
d1 $ s "hh*8"
  # up "1 2 3 4" -- caret is here

-- evals entire do block, not just indented multi line:
do
  d2 $ s "bd*2"
  d1 $ s "hh*8"
    # up "1 2 3 4" -- caret is here, ctrl-enter, evals entire do block :(

Well, I guess this is all is workable ~~if~~ when selection evaluation gets implemented.

lopho avatar Feb 09 '19 22:02 lopho

Ahhh, I see. Thanks for the PR I will pull down and test as soon as I can!

kindohm avatar Feb 09 '19 23:02 kindohm

Nice! I commented on the PR regarding ctrl+enter for evaluating selections containing multiple single line statements. After just reading the tidal atom readme regarding ctrl+enter, this should be the behavior on atom, but I'm almost certain it never actually worked that way, or was supposed to, but is broken.

lopho avatar Feb 09 '19 23:02 lopho

Implemented multi-line and single-line statement evaluation with selection. Got into a bit of trouble with the mocking system though. I wrote a bit more in length on the PR (#8).

lopho avatar Feb 12 '19 17:02 lopho

Not sure if this happens to you, but it's like the extension key bindings are not language specific to *.tidal files, but all instead. If I'm editing a Python file, and try to insert a new line below (Ctrl+Enter) it triggers tidal's eval command.

redraw avatar Apr 21 '21 23:04 redraw

This also breaks committing changes in the git view, as the keybinding is defined to be global. Setting it's when value to editorTextFocus might help a bit.

razzeee avatar Jul 11 '21 08:07 razzeee

I've set both keybindings to have "editorTextFocus && resourceExtname == '.tidal'" for its when expression and it works perfectly. Is this something that should be made default by the extension?

joanofxyz avatar May 24 '22 20:05 joanofxyz