【问题标题】:How do I open files in the most recently active Atom editor window instead of the Atom window I first opened?如何在最近活动的 Atom 编辑器窗口而不是我第一次打开的 Atom 窗口中打开文件?
【发布时间】:2017-04-20 17:42:35
【问题描述】:

在 Linux 上使用 Atom 编辑器时,我似乎无法在最近处于活动状态的 Atom 窗口中找到任何打开文件的选项(使用我的文件管理器)。相反,它总是在创建的第一个 Atom 窗口中打开。

我该如何解决这个问题?

【问题讨论】:

    标签: linux atom-editor archlinux


    【解决方案1】:

    有一个选项:

    -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;
            }
          }
    //    }
    

    …aaa 瞧!

    这是一个可破解的文本编辑器,毕竟^_^

    【讨论】:

    • 不幸的是,每次原子更新后都必须重做。
    • @Raj,那么在atom Github page 上提出问题不是更好吗?当前的行为显然不是预期的。
    • 顺便说一句,在阅读了更多代码之后,我很确定我的更正是合法的,因为它所做的只是颠倒 this.windowForPathsthis.lastFocusedWindow 的优先级。
    • 你是说我应该用你的确切更改创建一个拉取请求,因为它错误地颠倒了 this.windowForPathsthis.lastFocusedWindow 的优先级?
    • 我想我最好自己创建它。我不喜欢别人指责我的错误。
    猜你喜欢
    • 2018-02-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-30
    • 2023-02-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多