@@ -7,6 +7,7 @@ import { Logger } from '../logger';
77import { Messages } from '../messages' ;
88import { CommandQuickPickItem , CommitsQuickPick , ShowCommitSearchResultsInViewQuickPickItem } from '../quickpicks' ;
99import { Iterables , Strings } from '../system' ;
10+ import { SearchResultsCommitsNode } from '../views/nodes' ;
1011import {
1112 ActiveEditorCachedCommand ,
1213 command ,
@@ -39,13 +40,16 @@ export interface SearchCommitsCommandArgs {
3940 search ?: string ;
4041 searchBy ?: GitRepoSearchBy ;
4142 maxCount ?: number ;
43+ prefillOnly ?: boolean ;
4244 showInView ?: boolean ;
4345
4446 goBackCommand ?: CommandQuickPickItem ;
4547}
4648
4749@command ( )
4850export class SearchCommitsCommand extends ActiveEditorCachedCommand {
51+ private _lastSearch : string | undefined ;
52+
4953 constructor ( ) {
5054 super ( [ Commands . SearchCommits , Commands . SearchCommitsInView ] ) ;
5155 }
@@ -55,6 +59,12 @@ export class SearchCommitsCommand extends ActiveEditorCachedCommand {
5559 args = { ...args } ;
5660 args . showInView = true ;
5761
62+ if ( context . node instanceof SearchResultsCommitsNode ) {
63+ args . search = context . node . search ;
64+ args . searchBy = context . node . searchBy ;
65+ args . prefillOnly = true ;
66+ }
67+
5868 if ( isCommandViewContextWithRepo ( context ) ) {
5969 return this . execute ( context . editor , context . node . uri , args ) ;
6070 }
@@ -86,11 +96,21 @@ export class SearchCommitsCommand extends ActiveEditorCachedCommand {
8696 args = { ...args } ;
8797 const originalArgs = { ...args } ;
8898
99+ if ( args . prefillOnly && args . search && args . searchBy ) {
100+ args . search = `${ searchByToSymbolMap . get ( args . searchBy ) || '' } ${ args . search } ` ;
101+ args . searchBy = undefined ;
102+ }
103+
89104 if ( ! args . search || args . searchBy == null ) {
90105 let selection ;
91- if ( ! args . search && args . searchBy != null ) {
92- args . search = searchByToSymbolMap . get ( args . searchBy ) ;
93- selection = [ 1 , 1 ] ;
106+ if ( ! args . search ) {
107+ if ( args . searchBy != null ) {
108+ args . search = searchByToSymbolMap . get ( args . searchBy ) ;
109+ selection = [ 1 , 1 ] ;
110+ }
111+ else {
112+ args . search = this . _lastSearch ;
113+ }
94114 }
95115
96116 if ( args . showInView ) {
@@ -107,7 +127,7 @@ export class SearchCommitsCommand extends ActiveEditorCachedCommand {
107127 return args . goBackCommand === undefined ? undefined : args . goBackCommand . execute ( ) ;
108128 }
109129
110- originalArgs . search = args . search ;
130+ this . _lastSearch = originalArgs . search = args . search ;
111131
112132 const match = searchByRegex . exec ( args . search ) ;
113133 if ( match && match [ 1 ] ) {
@@ -198,7 +218,9 @@ export class SearchCommitsCommand extends ActiveEditorCachedCommand {
198218 : undefined ,
199219 showInViewCommand :
200220 log !== undefined
201- ? new ShowCommitSearchResultsInViewQuickPickItem ( log , { label : searchLabel ! } )
221+ ? new ShowCommitSearchResultsInViewQuickPickItem ( args . search , args . searchBy , log , {
222+ label : searchLabel !
223+ } )
202224 : undefined
203225 } ) ;
204226 if ( pick === undefined ) return undefined ;
0 commit comments