-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Run single function OR highlighted code #8344
Comments
How would you pass arguments to the function? |
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 |
Do you have any examples from other ide/editors that support this feature? |
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. |
no, original idea |
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. |
*not every language is compiled |
Right, a compiled language would need to be compiled, an interpreted language would need an interpreter / repl. |
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 |
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 |
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? |
I think this is really what I'm after. I write Rust and want to be able to run |
I've changed the title. Now we're going with right click (secondary click) of a function name or selected code. |
just to be clear, zed does have a 'run current script in the integrated terminal' like vscode right? |
rust is trickier by nature as it's compiled, it's doable though if the devs spend time on it. interpreted is much easier. |
Using the development tasks is making it easier. Would be great if the tasks can be bound to keystrokes |
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? |
sorry to come to this discussion late, but i have one more suggestion: |
no apologies needed! |
can you include a screen recording of that? |
are you sure? they seem related to me |
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)) |
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. |
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
The text was updated successfully, but these errors were encountered: