atom-project-util
Advanced tools
Comparing version 3.0.0 to 3.1.0
41
index.js
@@ -82,4 +82,10 @@ var fs = require('fs') | ||
// shim atom.deserialize in <= 1.6 | ||
function atomDeserialize (state) { | ||
// Atom >= 1.17 | ||
// There is a new API for deserializing state into an active window | ||
if (atom.restoreStateIntoThisEnvironment) { | ||
return atom.restoreStateIntoThisEnvironment(state); | ||
} | ||
// Atom < 1.17 | ||
if (atom.deserialize != null) return atom.deserialize(state) | ||
@@ -108,9 +114,13 @@ | ||
function loadState (key) { | ||
if (atom.loadState != null) { | ||
return atom.loadState(key); | ||
} | ||
if (atom.stateStore != null) { | ||
// Atom 1.7+ | ||
return atom.stateStore.load(key) | ||
} else { | ||
// Atom <= 1.6 | ||
return Promise.resolve(atom.getStorageFolder().load(key)) | ||
} | ||
// Atom <= 1.6 | ||
return Promise.resolve(atom.getStorageFolder().load(key)) | ||
} | ||
@@ -146,2 +156,21 @@ | ||
loadState(newStateKey).then((state) => { | ||
// HACK: Unload the active projects. This is _needed_ as of | ||
// Atom 1.17 but apparently it should have been done earlier as | ||
// well. I don't think there was any "bad" effects but eh, | ||
// here we go I guess. | ||
atom.project.getPaths().forEach(path => { | ||
atom.project.removePath(path) | ||
}) | ||
// Destroy the tabs | ||
// Fixes memory leak that was present in <= 3.x of this package | ||
var tabs = atom.packages.getActivePackage('tabs') | ||
if (tabs) { | ||
for (var i = 0; i < tabs.mainModule.tabBarViews.length; i++) { | ||
tabs.mainModule.tabBarViews[i].destroy(); | ||
} | ||
tabs.mainModule.tabBarViews.splice(0); | ||
} | ||
if (state) { | ||
@@ -189,2 +218,6 @@ // Deserialize state (this is what does the grunt of the work) | ||
// HACK: Toggle find-and-replace | ||
atom.packages.disablePackage('find-and-replace') | ||
atom.packages.enablePackage('find-and-replace') | ||
// Done | ||
@@ -191,0 +224,0 @@ resolve() |
{ | ||
"name": "atom-project-util", | ||
"version": "3.0.0", | ||
"version": "3.1.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9732
203