File tree Expand file tree Collapse file tree 2 files changed +22
-9
lines changed Expand file tree Collapse file tree 2 files changed +22
-9
lines changed Original file line number Diff line number Diff line change 1+ import type { Detail } from "jsr:@vim-fall/core@^0.2.1/item" ;
2+ import type { Source } from "jsr:@vim-fall/core@^0.2.1/source" ;
3+ import type { Action } from "jsr:@vim-fall/core@^0.2.1/action" ;
4+
5+ /**
6+ * Create a source for actions.
7+ */
8+ export function action (
9+ actions : Record < string , Action < Detail > > ,
10+ ) : Source < Action < Detail > > {
11+ return {
12+ collect : async function * ( ) {
13+ yield * Object . entries ( actions ) . map ( ( [ name , action ] , id ) => ( {
14+ id,
15+ value : name ,
16+ detail : action ,
17+ } ) ) ;
18+ } ,
19+ } ;
20+ }
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import {
1212 loadUserConfig ,
1313} from "../config.ts" ;
1414import { isOptions , isParams , isStringArray } from "../util/predicate.ts" ;
15+ import { action as buildActionSource } from "../extension/source/action.ts" ;
1516import { Picker } from "../picker.ts" ;
1617
1718let zindex = 50 ;
@@ -68,15 +69,7 @@ async function startPicker(
6869 const actionPicker = stack . use (
6970 new Picker ( {
7071 name : "@action" ,
71- source : {
72- collect : async function * ( ) {
73- yield * Object . entries ( params . actions ) . map ( ( [ name , action ] , id ) => ( {
74- id,
75- value : name ,
76- detail : action ,
77- } ) ) ;
78- } ,
79- } ,
72+ source : buildActionSource ( params . actions ) ,
8073 ...getActionPickerParams ( ) ,
8174 zindex,
8275 } ) ,
You can’t perform that action at this time.
0 commit comments