如何打开最近激活的Atom编辑器窗口中的文件,而不是首次打开的Atom窗口?
问题描述:
在Linux上使用Atom编辑器,我似乎无法找到任何选项在最近激活的Atom窗口中打开文件(使用我的文件管理器)。相反,它始终在创建的第一个Atom窗口中打开。如何打开最近激活的Atom编辑器窗口中的文件,而不是首次打开的Atom窗口?
我该如何解决这个问题?
答
有这个选项:
-a, --add Open path as a new project in last used window. [boolean]
...但无论如何,预期这是行不通的。但是,我发现了一个解决方法。
此代码位于某处周围src/main-process/atom-application.js
的862线:
if (existingWindow == null) {
if (currentWindow = window != null ? window : this.lastFocusedWindow) {
if (addToLastWindow || currentWindow.devMode === devMode && (stats.every(function(stat) {
return typeof stat.isFile === "function" ? stat.isFile() : void 0;
}) || stats.some(function(stat) {
return (typeof stat.isDirectory === "function" ? stat.isDirectory() : void 0) && !currentWindow.hasProjectPath();
}))) {
existingWindow = currentWindow;
}
}
}
注释掉的第一行和其前右括号:
// if (existingWindow == null) {
if (currentWindow = window != null ? window : this.lastFocusedWindow) {
if (addToLastWindow || currentWindow.devMode === devMode && (stats.every(function(stat) {
return typeof stat.isFile === "function" ? stat.isFile() : void 0;
}) || stats.some(function(stat) {
return (typeof stat.isDirectory === "function" ? stat.isDirectory() : void 0) && !currentWindow.hasProjectPath();
}))) {
existingWindow = currentWindow;
}
}
// }
... aaaand瞧!
它了一个破解的文本编辑器,毕竟^ _^
这不得不遗憾的是每一个原子更新后重做。 – Raj
@Raj,那么在[atom Github页面](https://github.com/atom/atom/issues)上提出问题会更好吗?目前的行为显然不是预期的行为。 – hidefromkgb
而顺便说一句,更多的阅读了代码,我很确定我的修正是合法的,因为它所做的只是颠倒'this.windowForPaths'和'this.lastFocusedWindow'的优先级。 – hidefromkgb