[Editor] Add a menu item to execute selected text in the console
Filing from some feedback received today on IRC #devtools:
"Selecting text in debugger to evaluate in console. Couldn't figure out how to do that, but seems like a super easy convenience function. Just an extra right click entry that copies it over and runs it."
Yes, that's a great win. Chrome also uses the selection to show a preview. They started doing this 8 months or so ago.
Seems we need something along the lines of:
- add new text entry to the localization file "Evaluate in console"
- add this entry to a new menu item
- the menu item only appears when we right-click a selection of text
- the new menu item calls a function
- the function console logs the result of executing the selected text
I think we can add a consoleEvaluate action in actions/panel
export function consoleEvaluate(input) {
return ({ client }: ThunkArgs) => {
// check to see if there is a syntax error ...
// then evaluate
client.evaluate(`console.log(input)`)
}
}
/claim
Thanks for claiming the issue! :wave:
Here are some links for getting setup, contributing, and developing. We're always happy to answer questions in slack! If you become busy, feel free to /unclaim it.
:fox_face: Debugger team!
@jasonLaster @captainbrosset So when we run evaluateInConsole we seem to have 3 scenarios:
-
we are evaluating a variable, in which case we want to return: a) which variable was evaluated b) what the variable contained or undefined
-
we are evaluating a function content, in which case we want to return: a) which function was evaluated b) what the contents of the functions are
-
we are evaluating a function execution, in which case we want to return: a) which function was being executed b) what the contents of the functions are c) what the return value of the function is
Does that sound about right?
Merged. Closing.