debugger icon indicating copy to clipboard operation
debugger copied to clipboard

[Editor] Add a menu item to execute selected text in the console

Open captainbrosset opened this issue 9 years ago • 7 comments

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

captainbrosset avatar Sep 08 '17 13:09 captainbrosset

Yes, that's a great win. Chrome also uses the selection to show a preview. They started doing this 8 months or so ago.

jasonLaster avatar Sep 08 '17 13:09 jasonLaster

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

lukaszsobek avatar Dec 05 '17 09:12 lukaszsobek

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)`)
    }
}

jasonLaster avatar Dec 06 '17 21:12 jasonLaster

/claim

lukaszsobek avatar Dec 14 '17 08:12 lukaszsobek

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!

claim avatar Dec 14 '17 08:12 claim

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

lukaszsobek avatar Jan 22 '18 19:01 lukaszsobek

Merged. Closing.

lukaszsobek avatar Feb 16 '18 04:02 lukaszsobek