Skip to content

Commit bd0c69f

Browse files
Merge pull request #91 from MichaelCurrin/fix-support-gitlens
Fix: support Gitlens
2 parents 0a4179d + 3771d3b commit bd0c69f

File tree

2 files changed

+12
-15
lines changed

2 files changed

+12
-15
lines changed

docs/development/advanced/sandbox.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ If you prefer not use this approach, you can just compile and install the extens
99

1010
## Start sandbox
1111

12-
These are configured in the `.vscode` directory of the repo.
12+
These are configured in the `.vscode/launch.json` config.
1313

1414
Follow these steps:
1515

@@ -25,7 +25,7 @@ Follow these steps:
2525
- NB. You'll must run `npm run sb` **first** to ensure this directory exists and then run the debug action. Run that NPM command again whenever you want to clear the space and start over.
2626
1. Click the run button.
2727

28-
That will start a new sandboxed VS Code session which has the extension built using the local code and _enabled_, and all other extensions _disabled_. At a lower level, it runs `npm compile` and `npm watch`.
28+
That will start a new sandboxed VS Code session which has the extension built using the local code and _enabled_, and all other extensions _disabled_. At a lower level, it runs `npm compile` and `npm watch`. If you want to keep extensions enabled, remove the `--disable-extensions` flag in the launch config.
2929

3030
What is especially useful about this is that whenever an extension action is performed in the sandboxed VS Code window, if there are any logs for that then those will appear in the Debug Console of the _original_ VS Code window.
3131

src/extension.ts

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,17 @@ function _validateFoundRepos(git: API) {
2727
}
2828

2929
/**
30-
* Run autofill against one of multiples in the workspace.
31-
*
32-
* This is a rare flow.
33-
*
34-
* @param sourceControl Of type `vscode.SourceControl` with public `.rootUri`
35-
* and private `.rootUri`.
30+
* Run autofill against one of multiples in the workspace or when using GitLens on a single repo.
3631
*/
37-
async function _handleRepos(git: API, sourceControl: any) {
32+
async function _handleRepos(git: API, sourceControl: vscode.SourceControl) {
3833
// FIXME: Unfortunately this seems to only pick up the first repo and not find
39-
// second, etc.
34+
// second, etc. If you repository through to makeAndFillCommitMsg, getChanges
35+
// and diffIndex etc. and replace "getWorkspaceFolder" usage then that will work.
4036
const selectedRepo = git.repositories.find(repository => {
41-
const uri = sourceControl._rootUri;
37+
const uri = sourceControl.rootUri;
4238
if (!uri) {
43-
console.warn("_rootUri not set");
39+
console.warn("rootUri not set for current repo");
40+
return false;
4441
}
4542
return repository.rootUri.path === uri.path;
4643
});
@@ -63,14 +60,14 @@ async function _handleRepo(git: API) {
6360
/**
6461
* Choose the relevant repo and apply autofill logic on files there.
6562
*/
66-
async function _chooseRepoForAutofill(uri?: vscode.Uri) {
63+
async function _chooseRepoForAutofill(sourceControl?: vscode.SourceControl) {
6764
const git = getGitExtension()!;
6865
_validateFoundRepos(git);
6966

7067
vscode.commands.executeCommand("workbench.view.scm");
7168

72-
if (uri) {
73-
_handleRepos(git, uri);
69+
if (sourceControl) {
70+
_handleRepos(git, sourceControl);
7471
} else {
7572
_handleRepo(git);
7673
}

0 commit comments

Comments
 (0)