Permalink
Browse files

Merge branch 'master' of github.com:scriptish/scriptish

  • Loading branch information...
2 parents 96bc305 + d6c34c1 commit 7a514041f556ab1415e61933f29ab5a3141aa45b @erikvold erikvold committed Sep 6, 2011
Showing with 35 additions and 4 deletions.
  1. +4 −2 extension/content/js/newscript.js
  2. +31 −2 extension/modules/utils/Scriptish_openInEditor.js
@@ -109,8 +109,10 @@ function doInstall() {
Scriptish_openInEditor(script, window);
// persist values
- Scriptish_prefRoot.setValue("newscript_namespace", script.namespace);
- Scriptish_prefRoot.setValue("newscript_author", script.author);
+ if (script.namespace)
+ Scriptish_prefRoot.setValue("newscript_namespace", script.namespace);
+ if (script.author)
+ Scriptish_prefRoot.setValue("newscript_author", script.author);
return true;
}
@@ -22,13 +22,42 @@ function Scriptish_openInEditor(script, parentWindow) {
spWin.addEventListener("load", function spWinLoaded() {
spWin.removeEventListener("load", spWinLoaded, false);
spWin.document.title = spWin.Scratchpad.filename = file.path;
- spWin.Scratchpad.importFromFile(file);
+
+ // Open the user script in Scratchpad
+ // NOTE: Resetting the "undo/redo" state on our own until Scratchpad
+ // handles it. We want to ensure user scripts don't get screwed up.
+ // See: https://bug684546.bugzilla.mozilla.org/
+ spWin.Scratchpad.importFromFile(file, false, function() {
+ let spEditor = spWin.Scratchpad.editor;
+
+ // For the Orion editor...
+ if (spEditor && spEditor._undoStack && spEditor._undoStack.reset) {
+ spEditor._undoStack.reset();
+ return;
+ }
+
+ // If not using Orion, pick out the proper editor
+ // Scratchpad in FF6 still uses 'textbox'
+ if (spEditor && spEditor._editor)
+ spEditor = spEditor._editor;
+ else if (spWin.Scratchpad.textbox)
+ spEditor = spWin.Scratchpad.textbox.editor;
+
+ if (spEditor
+ && spEditor.resetModificationCount
+ && spEditor.transactionManager
+ && spEditor.transactionManager.clear) {
+ spEditor.resetModificationCount();
+ spEditor.transactionManager.clear();
+ }
+ });
}, false);
}
else {
Scriptish_launchApplicationWithDoc(editor, file);
}
- } catch (e) {
+ }
+ catch (e) {
// Something may be wrong with the editor the user selected. Remove it.
Scriptish_alert(Scriptish_stringBundle("editor.couldNotLaunch") + "\n" + e);
Scriptish_prefRoot.remove("editor");

0 comments on commit 7a51404

Please sign in to comment.