Closed Bug 1578283 Opened 11 months ago Closed 11 months ago

Pressing Tab causes scrolling in the editor when it overflows

Categories

(DevTools :: Console, defect, P2)

71 Branch
x86_64
Linux
defect

Tracking

(firefox71 fixed)

RESOLVED FIXED
Firefox 71
Tracking Status
firefox71 --- fixed

People

(Reporter: 326374, Assigned: nchevobbe)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

What were you doing?

  1. Open the new multiline editor in the Console (Ctrl+B)
  2. Write a long script (that causes a scrollbar)
  3. Scroll all the way up (so that line 1 is visible)
  4. Put the cursor on the second line
  5. Press Tab

What happened?

The window was automatically scrolled, so that the top line is line 2.

What should have happened?

No scrolling.

Anything else we should know?

The bug occurs in safe mode.
Nightly build: 20190902094857

Thanks for filing this bug Dan.
I do reproduce the issue, and I should have a fix ready today :)

Assignee: nobody → nchevobbe
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Priority: -- → P2
Summary: Pressing Tab causes scrolling in the multiline editor → Pressing Tab causes scrolling in the editor when it overflows

When we wanted to insert a string in the webconsole input,
we were setting the input value, and setting the cursor
manually. But since the editor setCursor function is calling
alignLine, there could be cases where the editor scroll position
would jump, feeling awkward for the user.
It turns out we can simplify this code a lot since codeMirror
provides a replaceRange function, which is a perfect replacement
for what we were using, without having to manage the cursor position.

The only downside to that is that inserting characters this
way does fire a changes event, that we are listening to
in the JsTerm to request autocompletion (which we don't need
as we only insert characters when accepting a completion or
adding a tab).
To mitigate that, we pass a specific jsterm origin string to
replaceRange, which let's us discriminate in the changes event
listener if those changes originate from jsterm only actions.

A test is added to ensure this works as expected (the test was
failing without the fix).

Pushed by nchevobbe@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/a5d8176fb2eb
Don't scroll jsterm viewport when inserting a tab character. r=Honza.
Status: ASSIGNED → RESOLVED
Closed: 11 months ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 71
QA Whiteboard: [qa-71b-p2]
You need to log in before you can comment on or make changes to this bug.