Skip to content

Commit 838903f

Browse files
authored
add simple way to search within changed files (#103)
1 parent 7e2e89d commit 838903f

File tree

4 files changed

+26
-0
lines changed

4 files changed

+26
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ In bigger projects with many files it also provides **context**, it gives you a
2626

2727
- Log output of all git commands run
2828

29+
- Search within changed files
30+
2931
## Location
3032

3133
By default, the tree view is located in its own container accessible from the activity bar on the left. However, it can be freely moved to any other location like Source Control or Explorer by dragging and dropping.

package.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,12 @@
147147
"title": "View as Tree",
148148
"icon": "$(list-tree)",
149149
"category": "Git Tree Compare"
150+
},
151+
{
152+
"command": "gitTreeCompare.searchChanges",
153+
"title": "Search Changes",
154+
"icon": "$(search)",
155+
"category": "Git Tree Compare"
150156
}
151157
],
152158
"menus": {
@@ -220,6 +226,11 @@
220226
"command": "gitTreeCompare.viewAsTree",
221227
"when": "view == gitTreeCompare && gitTreeCompare.viewAsList",
222228
"group": "navigation@1"
229+
},
230+
{
231+
"command": "gitTreeCompare.searchChanges",
232+
"when": "view == gitTreeCompare",
233+
"group": "2_files"
223234
}
224235
],
225236
"view/item/context": [

src/extension.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ export function activate(context: ExtensionContext) {
8989
commands.registerCommand(NAMESPACE + '.viewAsTree', () => {
9090
runAfterInit(() => provider!.viewAsTree(true));
9191
});
92+
commands.registerCommand(NAMESPACE + '.searchChanges', () => {
93+
runAfterInit(() => provider!.searchChanges());
94+
});
9295

9396
createGit(gitApi, outputChannel).then(async git => {
9497
const onOutput = (str: string) => outputChannel.append(str);

src/treeProvider.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,6 +1103,16 @@ export class GitTreeCompareProvider implements TreeDataProvider<Element>, Dispos
11031103
this._onDidChangeTreeData.fire();
11041104
}
11051105

1106+
async searchChanges() {
1107+
const uris = [...this.iterFiles()].map(file => Uri.file(file.dstAbsPath));
1108+
const relativePaths = uris.map(uri => path.relative(this.repoRoot, uri.fsPath));
1109+
await commands.executeCommand('workbench.action.findInFiles', {
1110+
query: '',
1111+
filesToInclude: relativePaths.join(','),
1112+
triggerSearch: true
1113+
});
1114+
}
1115+
11061116
dispose(): void {
11071117
this.disposables.forEach(d => d.dispose());
11081118
}

0 commit comments

Comments
 (0)