Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tree-view] Ensure Explorer opens in focus on Windows #1167

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/tree-view/lib/tree-view.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const path = require('path');
const shell = require('electron').shell;
const remoteShell = require('electron').remote.shell;
const _ = require('underscore-plus');
const fs = require('fs-plus');
const { CompositeDisposable, Emitter } = require('atom');
Expand Down Expand Up @@ -822,7 +823,7 @@ class TreeView {
`Unable to show ${filePath} in ${this.getFileManagerName()}`
);
}
return shell.showItemInFolder(filePath);
return remoteShell.showItemInFolder(filePath);
}

showCurrentFileInFileManager() {
Expand All @@ -834,7 +835,7 @@ class TreeView {
`Unable to show ${filePath} in ${this.getFileManagerName()}`
);
}
return shell.showItemInFolder(filePath);
return remoteShell.showItemInFolder(filePath);
}

getFileManagerName() {
Expand Down
15 changes: 8 additions & 7 deletions packages/tree-view/spec/tree-view-package-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const path = require('path');
const temp = require('temp').track();
const os = require('os');
const {remote, shell} = require('electron');
const remoteShell = require('electron').remote.shell;
const Directory = require('../lib/directory');
const eventHelpers = require("./event-helpers");

Expand Down Expand Up @@ -4133,17 +4134,17 @@ describe("TreeView", function () {
});

describe("showSelectedEntryInFileManager()", function () {
beforeEach(() => spyOn(shell, 'showItemInFolder').andReturn(false));
beforeEach(() => spyOn(remoteShell, 'showItemInFolder').andReturn(false));

it("does nothing if no entry is selected", function () {
treeView.deselect();
treeView.showSelectedEntryInFileManager();
expect(shell.showItemInFolder).not.toHaveBeenCalled();
expect(remoteShell.showItemInFolder).not.toHaveBeenCalled();
});

it("shows the selected entry in the OS's file manager", function () {
treeView.showSelectedEntryInFileManager();
expect(shell.showItemInFolder).toHaveBeenCalled();
expect(remoteShell.showItemInFolder).toHaveBeenCalled();
});

it("displays a notification if showing the file fails", function () {
Expand All @@ -4155,13 +4156,13 @@ describe("TreeView", function () {
});

describe("showCurrentFileInFileManager()", function () {
beforeEach(() => spyOn(shell, 'showItemInFolder').andReturn(false));
beforeEach(() => spyOn(remoteShell, 'showItemInFolder').andReturn(false));

it("does nothing when no file is opened", function () {
expect(atom.workspace.getCenter().getPaneItems().length).toBe(0);

treeView.showCurrentFileInFileManager();
expect(shell.showItemInFolder).not.toHaveBeenCalled();
expect(remoteShell.showItemInFolder).not.toHaveBeenCalled();
});

it("does nothing when only an untitled tab is opened", function () {
Expand All @@ -4170,7 +4171,7 @@ describe("TreeView", function () {
return runs(function () {
workspaceElement.focus();
treeView.showCurrentFileInFileManager();
expect(shell.showItemInFolder).not.toHaveBeenCalled();
expect(remoteShell.showItemInFolder).not.toHaveBeenCalled();
});
});

Expand All @@ -4181,7 +4182,7 @@ describe("TreeView", function () {

return runs(function () {
treeView.showCurrentFileInFileManager();
expect(shell.showItemInFolder).toHaveBeenCalled();
expect(remoteShell.showItemInFolder).toHaveBeenCalled();
});
});

Expand Down
Loading