tidalcycles / vscode-tidalcycles

Support for TidalCycles in VSCode
GNU General Public License v3.0
35 stars 11 forks source link

Eval selection #7

Open lopho opened 5 years ago

lopho commented 5 years ago

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.)

kindohm commented 5 years ago

@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.

lopho commented 5 years ago

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 commented 5 years ago

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.

kindohm commented 5 years ago

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

lopho commented 5 years ago

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 commented 5 years ago

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).

redraw commented 3 years ago

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.

razzeee commented 3 years ago

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.

joanofxyz commented 2 years ago

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?