Currently completions are only shown for named objects and strings in the console. If expression contains [, ( or { no completions are shown. Would be good if in all cases the value is known completions for the object would show up. Some cases to test with: []. ({'abc':'def'}). (function(){}).b Also "document." provides completions but "(document)." does not.
Created attachment 107497 [details] Patch Bit mixed feelings about adding this to the utils.rangeOfWord because it only makes sense on moving backwards. On the other hand, implementing the moving between textnodes again in a separate function wouldn't be good either. There is also an edge case where expression could change the input value depending on the execution count. Then there would be possibility that expression is already run first when getting the completions. Other way would be to parse it so that all objects/function bodies remain empty {} and arrays empty []. Then we could at least get the completions for prototype properties. In my opinion while debugging it adds very much more if we get all completions for the actual object. I believe same kind of multi-execution also occures on watched expressions. This should also fix a bug where previously "foo". provided completions but for example "foo{". didn't.
Comment on attachment 107497 [details] Patch Will it work with regex literals? Like /"/ or /[]]/. I don't think we should implement a JavaScript parser right here.
No it will not. Because / is in the ExpressionStopCharacters array. RegExp("['\"]"). will work fine now though. I realize that there are probably many more constructs like this and they all can't be supported but arrays. objects and functions are very frequently used. I think one of the best use cases for console is not to just type in variables but people use it to quickly try out some new ideas. The prompt should help them out as much as it can. For example I also think functions should complete to arguments array if it is available.
This works now.