Skip to content

Commit

Permalink
Merge branch 'master' of github.com:scriptish/scriptish
Browse files Browse the repository at this point in the history
  • Loading branch information
erikvold committed Sep 6, 2011
2 parents 96bc305 + d6c34c1 commit 7a51404
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
6 changes: 4 additions & 2 deletions extension/content/js/newscript.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
33 changes: 31 additions & 2 deletions extension/modules/utils/Scriptish_openInEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 7a51404

Please sign in to comment.