Skip to content

Commit 4e320a4

Browse files
authored
Merge pull request #88 from bendera/bugfix/issue-68-reopened
fix: show the proper repository in the new tab
2 parents cadee85 + 6750eaa commit 4e320a4

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22

33
All notable changes to the "commit-message-editor" extension will be documented in this file.
44

5-
### [0.24.0] - 2023-04-16
5+
## Unreleased
6+
7+
### Fixed
8+
9+
- Show the correct repository on the new tab if it was opened from the scm view by clicking on the pencil icon.
10+
11+
## [0.24.0] - 2023-04-16
612

713
### Fixed
814

src/commands/EditorController.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as vscode from 'vscode';
2+
import { Repository } from '../@types/git';
23
import { editorGroupNameMap, ViewColumnKey, ViewType } from '../definitions';
34
import GitService, { RepositoryInfo } from '../utils/GitService';
45
import EditorView from '../webviews/EditorView';
@@ -14,7 +15,7 @@ export default class EditorController {
1415
private _git: GitService
1516
) {}
1617

17-
openInTheMainView() {
18+
async openInTheMainView(repo: Repository) {
1819
const config = vscode.workspace.getConfiguration('commit-message-editor');
1920

2021
if (this._primaryEditorPanel) {
@@ -49,7 +50,19 @@ export default class EditorController {
4950

5051
this._ui = new UiApi(this._primaryEditorPanel.webview);
5152
this._ui.sendSCMInputBoxValue(this._git.getSCMInputBoxMessage());
52-
this._ui.sendRepositoryInfo(this._getRepositoryInfo());
53+
54+
if (repo && repo.rootUri) {
55+
const repoPath = repo.rootUri.path;
56+
const commits = await this._git.getRecentCommitMessagesByPath(repoPath);
57+
58+
this._ui.sendRepositoryInfo({
59+
numberOfRepositories: this._git.getNumberOfRepositories(),
60+
selectedRepositoryPath: repoPath,
61+
});
62+
this._ui.sendRecentCommits(commits);
63+
} else {
64+
this._ui.sendRepositoryInfo(this._getRepositoryInfo());
65+
}
5366

5467
this._initReceivedMessageListener();
5568
this._git.onRepositoryDidChange(this._handleRepositoryDidChangeBound);

0 commit comments

Comments
 (0)