IAT doesn't work correctly with Orion editor in XUL (stylish)
Platform: Firefox 22b1, source Ubuntu official ~mozillateam (https://launchpad.net/~mozillateam/+archive/firefox-next), Ubuntu 12.10 amd64
IAT seems to work at least partially, insofar as I can tap the "edit" hover, change the contents of a text file in an external editor, save, and get the changed contents back in a text field. However, the temp file hangs out there after it's been closed in the editor, and seems to survive browser restarts (warm restart, cold start to new session, etc.).
This is screwing with Stylish something fierce, and I nearly lost a very complex userstyle to it. I'm using Sublime Text 2 ( http://www.sublimetext.com/dev ) for amd64 Linux. Don't know if that's related. fuser reports no file locks remaining after Sublime closes the file.
@rmenessec It cleans file up after a week. This is so that browser crashes don't delete the files.
Does that match what you're seeing?
Can I ask how you almost lost text? I'd be interested in fixing that UX.
I've also changed when the cleanWorkingDir() is called in 1.8.1 to ensure it is running when it should.
Oh, also, it only runs when a new window opens. So if you're a use-only-a-single-window-forever person, then it'll be not run until you restart your window/browser.
Here's what I was about to post to the Stylish forum when I realized the problem was fixed by killing the temp files in IAT's temp dir:
[Fx 22b1, amd64 Ubuntu 12.10, official mozilla-team PPA]
After upgrade (no other changes) to 22b1, attempting to edit a style always results in a window with the contents of the very first style in the list (a UI style, in this case). If I attempt to edit that style on purpose, all works as expected. If I attempt to edit another style, get the contents of the first style, and close the editing window, I get a prompt asking me if I'd like to save changes--implying that the correct style is "being edited", but it'll get overwritten with the contents of the first style.
Attempting to create a new style once again results in an editing window with the contents of the first style, and a prompt asking if I'd like to save changes if I close the editing window.
Oh, yes: specifically, I killed off the temp files with Firefox still running. Then the Stylish editor and IAT seemed to interact correctly, at least for a single test.
...and I just realized I didn't respond to your first question (sorry, rushing): I have no idea if IAT is cleaning up after a week. I'm afraid I don't have a convenient VM to test that in. Some of my gear is practically Stone Age: two cores and 8GiB of RAM max. ;)
Not cleaning up temp files for a week seems... untidy. Is there any way to hook Firefox to find out if IAT is running again after a clean shut-down? (I use the Session Manager addon.) I do understand the rationale, and appreciate the effort to make IAT crash-proof, of course.
Ah, okay.
The reason this seems so broken is because Stylish uses the Orion editor and IAT doesn't know how to talk to it.
I filed a bug with Stylish to ask for help. Hopefully @JasonBarnabe can help me out.
Ciao!
Interesting! I thought the switch to Orion was never made because it never got properly finished in Gecko. Wasn't there a switch to turn it off? Or are all of us (Stylish users) forced to use it now?
I'd be happy to switch off Orion as a work-around.
@rmenessec You can turn it off by:
- Go to the url about:config.
- Search for
extensions.stylish.editor - Double click on the
0and change it to1.
Now Stylish will use a plain old textbox (no syntax highlighting, etc.).
I'm afraid it's been set to '1' for a long time. I also use Stylish-Custom... whatever the last released version was ...and it's got UI for that preference, with the parenthetical text "not working". I don't know if that's still the case for a release of Stylish (1.3.2) post-Stylish-Custom-death-of-development.
Huh. With it set to 1 for me it works fine with IAT.
I guess we'll have to wait for @JasonBarnabe...
IAT is set up to read from some element where it can get/set the "value" property, correct? If so, then it's not going to work well with Orion.
Stylish internally uses this code to read/write from the code box, depending on the user's editor preference. The solution would be to tell IAT to use specified functions for this rather than an element. I think I could do this on my end, but to support others, you may want to it on yours.
Is there a function that Stylish could call to tell IAT to fire up, and is there a function/event that IAT calls that Stylish could listen to when the text is updated? I can make it work with Orion if I had those things.
What I'm trying now is to add the functions IAT is calling to the box that Orion/CodeMirror is attaching to. I do this:
sourceEditorElement.__defineGetter__('value',function() {return codeElementWrapper.value;});
sourceEditorElement.__defineSetter__('value',function(v) {codeElementWrapper.value = v;});
document.getElementById("itsalltext").setAttribute("itsalltext-control", sourceEditorElement.id);
However, when I click on IAT, nothing happens, not even anything in the error console. I assume it's expecting other attributes to be available and is swallowing whatever error is happening.
I've also tried calling it with JS as mentioned in the source code
<button id="itsalltext" label="&openintexternaleditor;" accesskey="&openintexternaleditor.ak;" onclick="
itsalltext.openEditor('sourceeditor', '.css');"/>
but that doesn't seem to work (openEditor isn't defined?)