Closed Bug 2064575 Opened 1 month ago Closed 19 days ago

"Go to line" sets a cursor line which does not exist in footer location indicator

Categories

(DevTools :: Debugger, defect, P3)

defect

Tracking

(firefox157 fixed)

RESOLVED FIXED
157 Branch
Tracking Status
firefox157 --- fixed

People

(Reporter: bomsy, Assigned: sevenwithawp)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

Steps to reproduce:

-> 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.

Assignee: nobody → sevenwithawp

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.

Severity: -- → S3
Priority: -- → P3

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.

Flags: needinfo?(hmanilla)

(In reply to K from comment #3)

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.

This makes sense, go ahead.

Flags: needinfo?(hmanilla)
Status: NEW → RESOLVED
Closed: 19 days ago
Resolution: --- → FIXED
Target Milestone: --- → 157 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: