Skip to content

Commit 447c3ba

Browse files
author
Rachel Macfarlane
committed
Preserve focus on tree on file select, #198
1 parent cf70794 commit 447c3ba

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

src/commands.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,6 @@ export function registerCommands(context: vscode.ExtensionContext, prManager: IP
128128
base: true
129129
})
130130
});
131-
return vscode.commands.executeCommand('vscode.diff', previousFileUri, fileChange.filePath, `${fileChange.fileName} from ${commit.substr(0, 8)}`);
131+
return vscode.commands.executeCommand('vscode.diff', previousFileUri, fileChange.filePath, `${fileChange.fileName} from ${commit.substr(0, 8)}`, { preserveFocus: true });
132132
}));
133133
}

src/github/pullRequestOverview.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export class PullRequestOverviewPanel {
3434
// If we already have a panel, show it.
3535
// Otherwise, create a new panel.
3636
if (PullRequestOverviewPanel.currentPanel) {
37-
PullRequestOverviewPanel.currentPanel._panel.reveal(column);
37+
PullRequestOverviewPanel.currentPanel._panel.reveal(column, true);
3838
PullRequestOverviewPanel.currentPanel._panel.title = title;
3939
} else {
4040
PullRequestOverviewPanel.currentPanel = new PullRequestOverviewPanel(extensionPath, column || vscode.ViewColumn.One, title, pullRequestManager);

src/view/treeNodes/fileChangeNode.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,10 @@ export class FileChangeNode extends TreeNode implements vscode.TreeItem {
7272
}
7373
this.resourceUri = this.filePath;
7474

75-
let opts = {};
75+
let opts: vscode.TextDocumentShowOptions = {
76+
preserveFocus: true
77+
};
78+
7679
if (this.comments && this.comments.length) {
7780
let sortedActiveComments = this.comments.filter(comment => comment.position).sort((a, b) => {
7881
return a.position - b.position;
@@ -85,9 +88,7 @@ export class FileChangeNode extends TreeNode implements vscode.TreeItem {
8588
if (diffLine) {
8689
// If the diff is a deletion, the new line number is invalid so use the old line number. Ensure the line number is positive.
8790
let lineNumber = Math.max(getZeroBased(diffLine.type === DiffChangeType.Delete ? diffLine.oldLineNumber : diffLine.newLineNumber), 0);
88-
opts = {
89-
selection: new vscode.Range(lineNumber, 0, lineNumber, 0)
90-
};
91+
opts.selection = new vscode.Range(lineNumber, 0, lineNumber, 0);
9192
}
9293
}
9394
}

0 commit comments

Comments
 (0)