* SUMMARY Save Console Evaluations into Command Line variables $1-$99 ($n). Currently: - $0 is special (often the selected node in the DOM tree, or potentially other uses for the item in context within the frontend). - $1-$4 mean "the previous $0 values" pushed into this list. They are not useful or commonly used. Proposal: - $0 remains the same - $1-$99 assign to unique non-null/non-undefined console evaluations For example: js> 10 + 15 // new value, stashed in $n <- 25 = $1 js> "hello" + "world" // new value, stashed in $n <- "helloworld" = $2 js> [$1, $2] // new value, stashed in $n <- [25, "helloworld"] = $3 js> null // not a useful value, do not stash <- null js> 100 - 75 // value already stashed (strict equality existing values), show the existing $n <- 25 = $1
<rdar://problem/19976979>
Created attachment 247459 [details] [PATCH] Proposed Fix
Created attachment 247460 [details] [IMAGE] Basic $n in console
Created attachment 247461 [details] [IMAGE] UI in Preview / Tree and Property Path tooltips
Created attachment 247462 [details] [IMAGE] Looping, after $99 reuse $1...
Comment on attachment 247459 [details] [PATCH] Proposed Fix View in context: https://bugs.webkit.org/attachment.cgi?id=247459&action=review > Source/JavaScriptCore/inspector/InjectedScriptSource.js:841 > + for (var i = 1; i < this._savedResults.length; ++i) { > + if (this._savedResults[i] === result) { > + this._savedResultIndex = i; > + return; > + } > + } var existingIndex = this._savedResults.indexOf(result); if (existingIndex != -1) { this._savedResultIndex = existingIndex; return; } > Source/JavaScriptCore/inspector/InjectedScriptSource.js:1189 > + this.__defineGetter__("$" + i, bind(injectedScript._savedResult, injectedScript, i)); Slick. > Source/WebCore/inspector/CommandLineAPIModuleSource.js:127 > + this.__defineGetter__("$" + i, bind(injectedScript._savedResult, injectedScript, i)); Why do we need this twice again? > Source/WebInspectorUI/UserInterface/Views/ConsoleMessageImpl.js:334 > + if (!this.savedResultIndex) > + return null; What will this display as?
(In reply to comment #6) > Comment on attachment 247459 [details] > [PATCH] Proposed Fix > > View in context: > https://bugs.webkit.org/attachment.cgi?id=247459&action=review > > > Source/JavaScriptCore/inspector/InjectedScriptSource.js:841 > > + for (var i = 1; i < this._savedResults.length; ++i) { > > + if (this._savedResults[i] === result) { > > + this._savedResultIndex = i; > > + return; > > + } > > + } > > var existingIndex = this._savedResults.indexOf(result); > if (existingIndex != -1) { > this._savedResultIndex = existingIndex; > return; > } Nice! > > Source/JavaScriptCore/inspector/InjectedScriptSource.js:1189 > > + this.__defineGetter__("$" + i, bind(injectedScript._savedResult, injectedScript, i)); > > Slick. > > > Source/WebCore/inspector/CommandLineAPIModuleSource.js:127 > > + this.__defineGetter__("$" + i, bind(injectedScript._savedResult, injectedScript, i)); > > Why do we need this twice again? We have BasicCommandLineAPI (JSContext) and CommandLineAPI (Web Page / DOM aware). Someday I will try to merge the two to prevent duplication. Already JSContext inspection lacks command line api basics like "keys", "values", "dir", "log", etc. However we provide a few basics with no outside knowledge. See <rdar://problem/19184801> for even more thoughts on this. > > Source/WebInspectorUI/UserInterface/Views/ConsoleMessageImpl.js:334 > > + if (!this.savedResultIndex) > > + return null; > > What will this display as? The default root property path in ObjectTreeView will be "obj": this._propertyPath = propertyPath || new WebInspector.PropertyPath(this._object, "obj"); Suggestions welcome.
> > > Source/WebInspectorUI/UserInterface/Views/ConsoleMessageImpl.js:334 > > > + if (!this.savedResultIndex) > > > + return null; > > > > What will this display as? > > The default root property path in ObjectTreeView will be "obj": > > this._propertyPath = propertyPath || new > WebInspector.PropertyPath(this._object, "obj"); > > Suggestions welcome. Changing to "this" per IRC discussion.
http://trac.webkit.org/changeset/180715
*** Bug 140864 has been marked as a duplicate of this bug. ***