@@ -15,7 +15,7 @@ import {
1515 getCurrentScopes
1616} from "../shared" ;
1717import { generateMessage } from "./message" ;
18- // import { fuzzyFilter } from "@cz-git/inquirer";
18+ import { fuzzyFilter } from "@cz-git/inquirer" ;
1919
2020export const generateQuestions = ( options : CommitizenGitOptions , cz : any ) => {
2121 if ( ! Array . isArray ( options . types ) || options . types . length === 0 ) {
@@ -29,21 +29,21 @@ export const generateQuestions = (options: CommitizenGitOptions, cz: any) => {
2929 name : "type" ,
3030 message : options . messages ?. type ,
3131 source : ( _ : unknown , input : string ) => {
32- const typesSource = options . types ?. concat ( options . typesAppend || [ ] ) || [ ] ;
33- return typesSource . filter ( ( item ) => ( input ? item . value . includes ( input ) : true ) ) || true ;
32+ const typeSource = options . types ?. concat ( options . typesAppend || [ ] ) || [ ] ;
33+ return fuzzyFilter ( input , typeSource , " value" ) ;
3434 }
3535 } ,
3636 {
3737 type : "autocomplete" ,
3838 name : "scope" ,
3939 message : options . messages ?. scope ,
4040 source : ( answer : Answers , input : string ) => {
41- let scopes : Option [ ] = [ ] ;
42- scopes = handleStandardScopes (
41+ let scopeSource : Option [ ] = [ ] ;
42+ scopeSource = handleStandardScopes (
4343 getCurrentScopes ( options . scopes , options . scopeOverrides , answer . type )
4444 ) ;
45- scopes = handleCustomTemplate (
46- scopes ,
45+ scopeSource = handleCustomTemplate (
46+ scopeSource ,
4747 cz ,
4848 options . customScopesAlign ,
4949 options . emptyScopesAlias ,
@@ -52,7 +52,7 @@ export const generateQuestions = (options: CommitizenGitOptions, cz: any) => {
5252 options . allowEmptyScopes ,
5353 options . defaultScope as string
5454 ) ;
55- return scopes ?. filter ( ( item ) => ( input ? item . name ?. includes ( input ) : true ) ) || true ;
55+ return fuzzyFilter ( input , scopeSource ) ;
5656 } ,
5757 when : ( answer : Answers ) => {
5858 return ! isSingleItem (
@@ -159,7 +159,7 @@ export const generateQuestions = (options: CommitizenGitOptions, cz: any) => {
159159 name : "footerPrefix" ,
160160 message : options . messages ?. footerPrefixsSelect ,
161161 source : ( _ : Answers , input : string ) => {
162- const issues = handleCustomTemplate (
162+ const issuePrefixSource = handleCustomTemplate (
163163 options . issuePrefixs as Option [ ] ,
164164 cz ,
165165 options . customIssuePrefixsAlign ,
@@ -168,7 +168,7 @@ export const generateQuestions = (options: CommitizenGitOptions, cz: any) => {
168168 options . allowCustomIssuePrefixs ,
169169 options . allowEmptyIssuePrefixs
170170 ) ;
171- return issues ?. filter ( ( item ) => ( input ? item . name ?. includes ( input ) : true ) ) || true ;
171+ return fuzzyFilter ( input , issuePrefixSource ) ;
172172 } ,
173173 when : ( ) =>
174174 ! isSingleItem (
0 commit comments