Open
Bug 1894683
Opened 1 year ago
Updated 1 year ago
In the Outline view, "Copy function" context menu is disabled for one-liner functions
Categories
(DevTools :: Debugger, defect, P3)
DevTools
Debugger
Tracking
(Not tracked)
NEW
People
(Reporter: nchevobbe, Unassigned)
Details
Steps to reproduce
- Open the console
- Evaluate the following
function x() { console.log("hello"); }
function y() {
console.log("world")
}
debugger;
- Once the debugger pauses, select the Outline view
- Right-click on
x
Expected results
The "Copy function" context menu is enabled
Actual results
The "Copy function" context menu is disabled
You can see that the context menu is enabled for y
| Reporter | ||
Comment 1•1 year ago
|
||
The issue comes from https://searchfox.org/mozilla-central/rev/f1532761de0b60337e42c6c3f525288a523dabef/devtools/client/debugger/src/utils/ast.js#24,29-30,32-38,55-56
function findClosestofSymbol(declarations, location) {
...
return declarations.reduce((found, currNode) => {
if (
...
!containsPosition(currNode.location, {
line: location.line,
column: location.column || 0,
})
) {
return found;
}
...
}, null);
}
we're returning found, which is always null, since it's the initial value passed into reduce
Comment 2•1 year ago
|
||
We should allow copying the function even if it's empty, so this should be easy to fix.
Severity: -- → S3
Priority: -- → P3
You need to log in
before you can comment on or make changes to this bug.
Description
•