Closed
Bug 843597
Opened 11 years ago
Closed 10 years ago
ScratchpadManager.openScratchpad() puts the cursor at the bottom
Categories
(DevTools Graveyard :: Scratchpad, defect, P3)
DevTools Graveyard
Scratchpad
Tracking
(Not tracked)
RESOLVED
FIXED
Firefox 27
People
(Reporter: arantius, Unassigned)
Details
User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:19.0) Gecko/20100101 Firefox/19.0 Build ID: 20130215130331 Steps to reproduce: I added a feature to Greasemonkey to use Scratchpad as the default script editor. https://github.com/greasemonkey/greasemonkey/commit/4fab342c6e47af47b4ee38b011693845999ebe68#L3R1 Actual results: I'm calling ScratchpadManager.openScratchpad() with a filename argument, which it seems to support -- but it doesn't read that file into the editor, so I'm also specifying the text argument. Which it puts into the editor, but it then puts the cursor at the end of this text. Expected results: This is incongruent with the behavior that actually picking File>Open in Scratchpad displays: it puts the cursor at the top (as expected). Pretty much every editor, when opening a new initial file at launch, or opening a file interactively, puts the cursor at the top of the file. Either: A) Supplying the filename argument to openScratchpad() should act exactly like picking that file after doing File>Open (read its contents, put it in the editor, put the cursor at the top), or B) The cursor should start at the top of the editor even when supplying initial text.
Comment 1•11 years ago
|
||
Scratchpad.openScratchpad takes an optional `state` argument, which is an object that looks like:
> {
> filename: "filename.js",
> text: "// javascript code goes here",
> executionContext: 1,
> saved: true
> }
`executionContext` is 1 for content, 2 for browser
saved indicates whether there's a * next to the name (AKA editor is dirty)
If you use ScratchpadManager.openScratchpad with options like this then it should open with the cursor at the top instead of the bottom as you desire.
Status: UNCONFIRMED → RESOLVED
Closed: 11 years ago
Resolution: --- → WORKSFORME
Reporter | ||
Comment 2•11 years ago
|
||
That's exactly what I've always been doing: https://github.com/greasemonkey/greasemonkey/blob/4fab342c6e47af47b4ee38b011693845999ebe68/modules/util/openInEditor.js#L18 Unless you're saying that the executionContext _must_ also be passed?
Status: RESOLVED → UNCONFIRMED
Resolution: WORKSFORME → ---
Comment 3•11 years ago
|
||
Oh hmm. I will investigate further.
Comment 4•11 years ago
|
||
You are absolutely right! I must have been seeing things.
Status: UNCONFIRMED → NEW
Ever confirmed: true
OS: Linux → All
Priority: -- → P3
Hardware: x86_64 → All
Version: 19 Branch → Trunk
Comment 5•11 years ago
|
||
As an interim solution until we get a fix landed, you can use `scratchpad.selectRange(0, 0)` (assuming you're not already doing this as a workaround).
Comment 6•11 years ago
|
||
Unfortunately, it does not always work. For example: https://github.com/greasemonkey/greasemonkey/issues/1785
Reporter | ||
Comment 7•10 years ago
|
||
So what's the situation here after bug 912260 ?
Comment 8•10 years ago
|
||
You can set the status to "RESOLVED FIXED", see: https://bugzilla.mozilla.org/show_bug.cgi?id=912260 https://github.com/greasemonkey/greasemonkey/commit/00989016c0c6648d8295399b8cdb58a175bb16ff
Comment 9•10 years ago
|
||
Thanks!
Status: NEW → RESOLVED
Closed: 11 years ago → 10 years ago
Resolution: --- → FIXED
Updated•10 years ago
|
Target Milestone: --- → Firefox 27
Updated•6 years ago
|
Product: Firefox → DevTools
Updated•4 years ago
|
Product: DevTools → DevTools Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•