Run single function OR highlighted code #23257
Replies: 25 comments
-
How would you pass arguments to the function? |
Beta Was this translation helpful? Give feedback.
-
i said 'prompted in the terminal'? not sure whats not being communicated here sorry. take the below pseudo code def coinToss (color, amount, speed): the terminal would be prompt me for all parameters (someone else can figure out if we should make the user define the variable type while inputting too) and it would then show the outputs of all variables and what returned. if the function is recursive it would display each recursuions values and if the function had args (undefined amount of parameters) the terminal would ask how many you want to put in or maybe have it just display return output, or have it as an option for the user. general idea |
Beta Was this translation helpful? Give feedback.
-
Do you have any examples from other ide/editors that support this feature? |
Beta Was this translation helpful? Give feedback.
-
Ah, sorry. Seems I skipped a line while reading. @SomeoneToIgnore One similar thing I can immediately think of is the Matlab GUI where you have a panel with an editable real-time listing of variables in global scope, which will be in force when you run code snippets. |
Beta Was this translation helpful? Give feedback.
-
no, original idea |
Beta Was this translation helpful? Give feedback.
-
It seems like this feature would require us to build custom support for every language. For example, for a single Rust function, we would need to hoist it into some compilable project so that we could run it. It seems like a huge lift to get that to work for one language, let alone many. |
Beta Was this translation helpful? Give feedback.
-
*not every language is compiled |
Beta Was this translation helpful? Give feedback.
-
Right, a compiled language would need to be compiled, an interpreted language would need an interpreter / repl. |
Beta Was this translation helpful? Give feedback.
-
well if the interpreter can read the whole project, it can read a single function too. compiled languages would cause issue however. am i missing something here |
Beta Was this translation helpful? Give feedback.
-
I think a good first step would be the ability to "pipe" selected text (or a syntactic node) to an external program. We could do that via tasks even. So say you select text, you hit |
Beta Was this translation helpful? Give feedback.
-
as long as it works with the virtual environment and has access to all modules and files thats fine
well the idea was just for functions but selected texts works too, we should still have the right click a function and have a "run function" option
by default, it should just use the interpreter of whatever the rest of the file sees. i feel like inputting a different interpreter is pretty niche but still should be considered
sounds fine to me but what about handling of recursive functions or functions with an undefined amount of parameters, etc.? do we just show recursion graphs and have a certain string to stop inputting? |
Beta Was this translation helpful? Give feedback.
-
I think this is really what I'm after. I write Rust and want to be able to run |
Beta Was this translation helpful? Give feedback.
-
I've changed the title. Now we're going with right click (secondary click) of a function name or selected code. |
Beta Was this translation helpful? Give feedback.
-
just to be clear, zed does have a 'run current script in the integrated terminal' like vscode right? |
Beta Was this translation helpful? Give feedback.
-
rust is trickier by nature as it's compiled, it's doable though if the devs spend time on it. interpreted is much easier. |
Beta Was this translation helpful? Give feedback.
-
Using the development tasks is making it easier. Would be great if the tasks can be bound to keystrokes |
Beta Was this translation helpful? Give feedback.
-
I want to reiterate that VS Code has RunSelectedText feature which is very useful for shell-wrangling (as mentioned in issue #8656 which is closed as duplicate to this). Instead of editing commands directly in Terminal, you edit your shell code in a good editor and ability to run it via single command is super useful. In this Issue, however, there is a need for a 'data input interface', which might be additional work. Maybe keep them separate? |
Beta Was this translation helpful? Give feedback.
-
sorry to come to this discussion late, but i have one more suggestion: |
Beta Was this translation helpful? Give feedback.
-
no apologies needed! |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
can you include a screen recording of that? |
Beta Was this translation helpful? Give feedback.
-
are you sure? they seem related to me |
Beta Was this translation helpful? Give feedback.
-
For those who want to run highlighted text, this is working well for me in {
"context": "Editor",
"bindings": {
"cmd-enter": ["workspace::SendKeystrokes", "cmd-c ctrl-` cmd-v enter"]
}
} (found from #16102 (comment)) |
Beta Was this translation helpful? Give feedback.
-
Thanks, that's great! Is there any way to make it work with the terminal on the right? I wrote a longer comment about this in #16102, perhaps best to discuss there. |
Beta Was this translation helpful? Give feedback.
-
need online help |
Beta Was this translation helpful? Give feedback.
-
Check for existing issues
Describe the feature
So you'd highlight a function via highlighting it with your mouse and then hit something like F6 (or maybe right click its name, whatever) and then you'd be prompted in the terminal to input the values of all the arguments and it would show you what the function returned as well as outputted (etc.). Useful debugging feature.
If applicable, add mockups / screenshots to help present your vision of the feature
No response
Beta Was this translation helpful? Give feedback.
All reactions