"Go to line" sets a cursor line which does not exist in footer location indicator
Categories
(DevTools :: Debugger, defect, P3)
Tracking
(firefox157 fixed)
| Tracking | Status | |
|---|---|---|
| firefox157 | --- | fixed |
People
(Reporter: bomsy, Assigned: sevenwithawp)
References
(Blocks 1 open bug)
Details
Attachments
(1 file)
Steps to reproduce:
- Go to https://nchevobbe.github.io/demo/console-test-app.html
- Open the Debugger.
- Open console-test-event-listeners.js.
- Press Ctrl+G to open the "Jump to line" UI.
- Enter 99.
-> The location indicator in the bottom-right corner shows (99, 1), even though line 99 doesn't exist and the cursor remains at its previous position.
| Reporter | ||
Updated•1 month ago
|
| Reporter | ||
Comment 1•1 month ago
|
||
Hi K, Assigned to you.
The cursor is set here https://searchfox.org/firefox-main/rev/b0bc20aac45f7cb55b18adbf4d2313457659d140/devtools/client/shared/sourceeditor/editor.js#3468-3469
...
this.openDialog(div, line => {
// Handle LINE:COLUMN as well as LINE
const match = line.toString().match(RE_JUMP_TO_LINE);
if (match) {
const [, matchLine, column] = match;
this.setCursor({ line: matchLine - 1, ch: column ? column - 1 : 0 });
}
});
...
Feel free to ask any questions.
Updated•1 month ago
|
Hi Hubert, thanks for the info!
It looks like openDialog isn't being called because the invalid line number is already caught by other checks. I can see several warnings/errors in the console:
console.warn: "Invalid line number 99999999 in 400-line document"
console.warn: "Invalid line number 99999999 in 400-line document"
console.warn: "Invalid line number 99999999 in 400-line document"
console.warn: "Invalid line number 99999999 in 400-line document"
console.error: "Trying to set the cursor on a non-existing line 99999999 > 400"
I did a bit more debugging and would like to propose validating the entered line number when the user presses Enter, before any further action is triggered.
We can get the total number of lines from the editor, and we already have the line number entered by the user, so it seems we could stop there if the requested line doesn't exist.
Please let me know if this sounds like the right direction.
| Reporter | ||
Comment 4•24 days ago
•
|
||
(In reply to K from comment #3)
Hi Hubert, thanks for the info!
It looks like
openDialogisn't being called because the invalid line number is already caught by other checks. I can see several warnings/errors in the console:console.warn: "Invalid line number 99999999 in 400-line document" console.warn: "Invalid line number 99999999 in 400-line document" console.warn: "Invalid line number 99999999 in 400-line document" console.warn: "Invalid line number 99999999 in 400-line document" console.error: "Trying to set the cursor on a non-existing line 99999999 > 400"I did a bit more debugging and would like to propose validating the entered line number when the user presses Enter, before any further action is triggered.
We can get the total number of lines from the editor, and we already have the line number entered by the user, so it seems we could stop there if the requested line doesn't exist.
Please let me know if this sounds like the right direction.
This makes sense, go ahead.
Comment 6•19 days ago
|
||
| bugherder | ||
Description
•