1
1
import {
2
2
BaseSource ,
3
- Candidate ,
4
3
fn ,
5
- GatherCandidatesArguments ,
4
+ GatherArguments ,
6
5
homeDir ,
6
+ Item ,
7
7
path as univPath ,
8
8
vars ,
9
9
wrapA ,
@@ -15,10 +15,10 @@ type Params = {
15
15
mode : "os" | "win32" | "posix" ;
16
16
takeFileNum : number ;
17
17
projMarkers : string [ ] ;
18
- cwdMaxCandidates : number ;
19
- bufMaxCandidates : number ;
20
- projFromCwdMaxCandidates : number [ ] ;
21
- projFromBufMaxCandidates : number [ ] ;
18
+ cwdMaxItems : number ;
19
+ bufMaxItems : number ;
20
+ projFromCwdMaxItems : number [ ] ;
21
+ projFromBufMaxItems : number [ ] ;
22
22
cwdAsRoot : boolean ;
23
23
bufAsRoot : boolean ;
24
24
projAsRoot : boolean ;
@@ -57,19 +57,19 @@ const existsDir = async (filePath: string): Promise<boolean> => {
57
57
} ;
58
58
59
59
export class Source extends BaseSource < Params > {
60
- async gatherCandidates (
61
- args : GatherCandidatesArguments < Params > ,
62
- ) : Promise < Candidate [ ] > {
60
+ async gather (
61
+ args : GatherArguments < Params > ,
62
+ ) : Promise < Item [ ] > {
63
63
const p = args . sourceParams ;
64
64
const mode = p . mode === "os"
65
65
? ( Deno . build . os === "windows" ? "win32" : "posix" )
66
66
: p . mode ;
67
67
const path = mode === "posix" ? univPath . posix : univPath . win32 ;
68
68
const maxOfMax = Math . max (
69
- p . cwdMaxCandidates ,
70
- p . bufMaxCandidates ,
71
- ...p . projFromCwdMaxCandidates ,
72
- ...p . projFromBufMaxCandidates ,
69
+ p . cwdMaxItems ,
70
+ p . bufMaxItems ,
71
+ ...p . projFromCwdMaxItems ,
72
+ ...p . projFromBufMaxItems ,
73
73
) ;
74
74
75
75
// e.g. (
@@ -162,23 +162,23 @@ export class Source extends BaseSource<Params> {
162
162
// point from cwd
163
163
findPointsAsync . push ( {
164
164
dir : cwd ,
165
- max : p . cwdMaxCandidates ,
165
+ max : p . cwdMaxItems ,
166
166
menu : p . displayCwd ,
167
167
asRoot : p . cwdAsRoot ,
168
168
} ) ;
169
169
170
170
// point from project-root found from cwd
171
171
findPointsAsync . push (
172
172
util . findMarkers (
173
- p . projFromCwdMaxCandidates . length ,
173
+ p . projFromCwdMaxItems . length ,
174
174
cwd ,
175
175
p . projMarkers ,
176
176
path ,
177
177
)
178
178
. then ( ( dirs ) =>
179
179
dirs . map ( ( dir , i ) => ( {
180
180
dir,
181
- max : p . projFromCwdMaxCandidates [ i ] ,
181
+ max : p . projFromCwdMaxItems [ i ] ,
182
182
menu : `${ p . displayCwd } ^${ i === 0 ? "" : i + 1 } ` ,
183
183
asRoot : p . projAsRoot ,
184
184
} ) )
@@ -192,22 +192,22 @@ export class Source extends BaseSource<Params> {
192
192
findPointsAsync . push ( {
193
193
dir : bufDir ,
194
194
menu : p . displayBuf ,
195
- max : p . bufMaxCandidates ,
195
+ max : p . bufMaxItems ,
196
196
asRoot : p . bufAsRoot ,
197
197
} ) ;
198
198
199
199
// point from project-root found from buf
200
200
findPointsAsync . push (
201
201
util . findMarkers (
202
- p . projFromBufMaxCandidates . length ,
202
+ p . projFromBufMaxItems . length ,
203
203
bufDir ,
204
204
p . projMarkers ,
205
205
path ,
206
206
)
207
207
. then ( ( dirs ) =>
208
208
dirs . map ( ( dir , i ) => ( {
209
209
dir,
210
- max : p . projFromBufMaxCandidates [ i ] ,
210
+ max : p . projFromBufMaxItems [ i ] ,
211
211
menu : `${ p . displayBuf } ^${ i === 0 ? "" : i + 1 } ` ,
212
212
asRoot : p . projAsRoot ,
213
213
} ) )
@@ -243,7 +243,7 @@ export class Source extends BaseSource<Params> {
243
243
} ) ) ,
244
244
) ;
245
245
246
- const candidatesList = await Promise . all (
246
+ const itemsList = await Promise . all (
247
247
resolvedFindPoints
248
248
. filter ( ( { ex } ) => ex )
249
249
. map ( ( { point } ) => point )
@@ -261,7 +261,7 @@ export class Source extends BaseSource<Params> {
261
261
( entry . isSymlink && p . followSymlinks &&
262
262
await existsDir ( path . join ( dir , entry . name ) ) ) ,
263
263
} ) )
264
- . map ( ( { name, isDirectory, isSymlink } ) : Candidate => ( {
264
+ . map ( ( { name, isDirectory, isSymlink } ) : Item => ( {
265
265
word : name . slice ( inputFileBasePrefix . length ) +
266
266
( p . trailingSlash && isDirectory ? path . sep : "" ) ,
267
267
abbr : name . slice ( inputFileBasePrefix . length ) +
@@ -282,10 +282,9 @@ export class Source extends BaseSource<Params> {
282
282
. catch ( ( ) => [ ] ) ,
283
283
) ,
284
284
) ;
285
- const candidates : Candidate [ ] = candidatesList
286
- . flat ( ) ;
285
+ const items : Item [ ] = itemsList . flat ( ) ;
287
286
288
- return candidates ;
287
+ return items ;
289
288
}
290
289
291
290
params ( ) : Params {
@@ -297,10 +296,10 @@ export class Source extends BaseSource<Params> {
297
296
".github" ,
298
297
] ,
299
298
takeFileNum : 10000 ,
300
- cwdMaxCandidates : 1000 ,
301
- bufMaxCandidates : 1000 ,
302
- projFromCwdMaxCandidates : [ 1000 ] ,
303
- projFromBufMaxCandidates : [ 1000 ] ,
299
+ cwdMaxItems : 1000 ,
300
+ bufMaxItems : 1000 ,
301
+ projFromCwdMaxItems : [ 1000 ] ,
302
+ projFromBufMaxItems : [ 1000 ] ,
304
303
cwdAsRoot : false ,
305
304
bufAsRoot : false ,
306
305
projAsRoot : true ,
0 commit comments