@@ -22,8 +22,10 @@ export async function showCommitPicker(
2222 placeholder : string ,
2323 options ?: {
2424 picked ?: string ;
25- keys ?: Keys [ ] ;
26- onDidPressKey ?( key : Keys , item : CommitQuickPickItem ) : void | Promise < void > ;
25+ keyboard ?: {
26+ keys : Keys [ ] ;
27+ onDidPressKey ( key : Keys , item : CommitQuickPickItem ) : void | Promise < void > ;
28+ } ;
2729 showOtherReferences ?: CommandQuickPickItem [ ] ;
2830 } ,
2931) : Promise < GitCommit | undefined > {
@@ -98,17 +100,23 @@ export async function showCommitPicker(
98100 const disposables : Disposable [ ] = [ ] ;
99101
100102 let scope : KeyboardScope | undefined ;
101- if ( options ?. keys != null && options . keys . length !== 0 && options ?. onDidPressKey !== null ) {
103+ if ( options ?. keyboard != null ) {
104+ const { keyboard } = options ;
102105 scope = Container . instance . keyboard . createScope (
103106 Object . fromEntries (
104- options . keys . map ( key => [
107+ keyboard . keys . map ( key => [
105108 key ,
106109 {
107- onDidPressKey : key => {
110+ onDidPressKey : async key => {
108111 if ( quickpick . activeItems . length !== 0 ) {
109112 const [ item ] = quickpick . activeItems ;
110113 if ( item != null && ! isDirectiveQuickPickItem ( item ) && ! CommandQuickPickItem . is ( item ) ) {
111- void options . onDidPressKey ! ( key , item ) ;
114+ const ignoreFocusOut = quickpick . ignoreFocusOut ;
115+ quickpick . ignoreFocusOut = true ;
116+
117+ await keyboard . onDidPressKey ( key , item ) ;
118+
119+ quickpick . ignoreFocusOut = ignoreFocusOut ;
112120 }
113121 }
114122 } ,
@@ -143,14 +151,14 @@ export async function showCommitPicker(
143151 resolve ( item ) ;
144152 }
145153 } ) ,
146- quickpick . onDidChangeValue ( async e => {
154+ quickpick . onDidChangeValue ( value => {
147155 if ( scope == null ) return ;
148156
149157 // Pause the left/right keyboard commands if there is a value, otherwise the left/right arrows won't work in the input properly
150- if ( e . length !== 0 ) {
151- await scope . pause ( [ 'left' , 'right' ] ) ;
158+ if ( value . length !== 0 ) {
159+ void scope . pause ( [ 'left' , 'ctrl+left' , 'right' , 'ctrl+ right'] ) ;
152160 } else {
153- await scope . resume ( ) ;
161+ void scope . resume ( ) ;
154162 }
155163 } ) ,
156164 ) ;
@@ -182,8 +190,10 @@ export async function showStashPicker(
182190 options ?: {
183191 empty ?: string ;
184192 filter ?: ( c : GitStashCommit ) => boolean ;
185- keys ?: Keys [ ] ;
186- onDidPressKey ?( key : Keys , item : CommitQuickPickItem < GitStashCommit > ) : void | Promise < void > ;
193+ keyboard ?: {
194+ keys : Keys [ ] ;
195+ onDidPressKey ( key : Keys , item : CommitQuickPickItem < GitStashCommit > ) : void | Promise < void > ;
196+ } ;
187197 picked ?: string ;
188198 showOtherReferences ?: CommandQuickPickItem [ ] ;
189199 } ,
@@ -231,17 +241,23 @@ export async function showStashPicker(
231241 const disposables : Disposable [ ] = [ ] ;
232242
233243 let scope : KeyboardScope | undefined ;
234- if ( options ?. keys != null && options . keys . length !== 0 && options ?. onDidPressKey !== null ) {
244+ if ( options ?. keyboard != null ) {
245+ const { keyboard } = options ;
235246 scope = Container . instance . keyboard . createScope (
236247 Object . fromEntries (
237- options . keys . map ( key => [
248+ keyboard . keys . map ( key => [
238249 key ,
239250 {
240- onDidPressKey : key => {
251+ onDidPressKey : async key => {
241252 if ( quickpick . activeItems . length !== 0 ) {
242253 const [ item ] = quickpick . activeItems ;
243254 if ( item != null && ! isDirectiveQuickPickItem ( item ) && ! CommandQuickPickItem . is ( item ) ) {
244- void options . onDidPressKey ! ( key , item ) ;
255+ const ignoreFocusOut = quickpick . ignoreFocusOut ;
256+ quickpick . ignoreFocusOut = true ;
257+
258+ await keyboard . onDidPressKey ( key , item ) ;
259+
260+ quickpick . ignoreFocusOut = ignoreFocusOut ;
245261 }
246262 }
247263 } ,
@@ -270,14 +286,14 @@ export async function showStashPicker(
270286 resolve ( item ) ;
271287 }
272288 } ) ,
273- quickpick . onDidChangeValue ( async e => {
289+ quickpick . onDidChangeValue ( value => {
274290 if ( scope == null ) return ;
275291
276292 // Pause the left/right keyboard commands if there is a value, otherwise the left/right arrows won't work in the input properly
277- if ( e . length !== 0 ) {
278- await scope . pause ( [ 'left' , 'right' ] ) ;
293+ if ( value . length !== 0 ) {
294+ void scope . pause ( [ 'left' , 'ctrl+left' , 'right' , 'ctrl+ right'] ) ;
279295 } else {
280- await scope . resume ( ) ;
296+ void scope . resume ( ) ;
281297 }
282298 } ) ,
283299 ) ;
0 commit comments