Commit 7d474cf4 authored by Benedikt Meurer's avatar Benedikt Meurer Committed by Commit Bot

[devtools] Limit eager (popover) evaluation to the innermost scope.

The eager evaluation when hovering expressions only works sort of
reliably inside the innermost scope anyways (even there we have cases
where we get it wrong), so in order to avoid confusing the developer,
limit it to the innermost scope for now.

Bug: chromium:995036
Change-Id: I6c44326ee5794df1ea6574cd6cf510419b6f4cfa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1835357Reviewed-by: default avatarYang Guo <yangguo@chromium.org>
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#701996}
parent 8b5bb377
......@@ -435,6 +435,12 @@ Sources.DebuggerPlugin = class extends Sources.UISourceCodeFrame.Plugin {
let startHighlight;
let endHighlight;
const selectedCallFrame =
/** @type {!SDK.DebuggerModel.CallFrame} */ (UI.context.flavor(SDK.DebuggerModel.CallFrame));
if (!selectedCallFrame) {
return null;
}
if (textSelection && !textSelection.isEmpty()) {
if (textSelection.startLine !== textSelection.endLine || textSelection.startLine !== mouseLine ||
mouseColumn < textSelection.startColumn || mouseColumn > textSelection.endColumn) {
......@@ -480,20 +486,34 @@ Sources.DebuggerPlugin = class extends Sources.UISourceCodeFrame.Plugin {
}
}
// The eager evaluation on works sort of reliably within the top-most scope of
// the selected call frame, so don't even try outside the top-most scope.
const [scope] = selectedCallFrame.scopeChain();
if (scope && scope.startLocation() && scope.endLocation()) {
if (editorLineNumber < scope.startLocation().lineNumber) {
return null;
}
if (editorLineNumber === scope.startLocation().lineNumber &&
startHighlight < scope.startLocation().columnNumber) {
return null;
}
if (editorLineNumber > scope.endLocation().lineNumber) {
return null;
}
if (editorLineNumber === scope.endLocation().lineNumber && endHighlight > scope.endLocation().columnNumber) {
return null;
}
}
let objectPopoverHelper;
let highlightDescriptor;
return {
box: anchorBox,
show: async popover => {
const selectedCallFrame = UI.context.flavor(SDK.DebuggerModel.CallFrame);
if (!selectedCallFrame) {
return false;
}
const evaluationText = this._textEditor.line(editorLineNumber).substring(startHighlight, endHighlight + 1);
const resolvedText = await Sources.SourceMapNamesResolver.resolveExpression(
/** @type {!SDK.DebuggerModel.CallFrame} */ (selectedCallFrame), evaluationText, this._uiSourceCode,
editorLineNumber, startHighlight, endHighlight);
selectedCallFrame, evaluationText, this._uiSourceCode, editorLineNumber, startHighlight, endHighlight);
const result = await selectedCallFrame.evaluate({
expression: resolvedText || evaluationText,
objectGroup: 'popover',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment