File tree Expand file tree Collapse file tree 2 files changed +38
-1
lines changed
providers/FileSystemPovider Expand file tree Collapse file tree 2 files changed +38
-1
lines changed Original file line number Diff line number Diff line change @@ -56,6 +56,14 @@ export interface SearchResult {
56
56
matches : SearchMatch [ ] ;
57
57
}
58
58
59
+ export interface DocSearchResult {
60
+ name : string ;
61
+ cat : "RTN" | "CLS" | "CSP" | "OTH" ;
62
+ ts : string ;
63
+ db : string ;
64
+ gen : boolean ;
65
+ }
66
+
59
67
export interface AtelierJob {
60
68
pid : number ;
61
69
namespace : string ;
Original file line number Diff line number Diff line change 1
1
import * as vscode from "vscode" ;
2
+ import { DocSearchResult } from "../../api/atelier" ;
3
+ import { AtelierAPI } from "../../api" ;
2
4
3
5
export class FileSearchProvider implements vscode . FileSearchProvider {
4
6
/**
@@ -12,6 +14,33 @@ export class FileSearchProvider implements vscode.FileSearchProvider {
12
14
options : vscode . FileSearchOptions ,
13
15
token : vscode . CancellationToken
14
16
) : vscode . ProviderResult < vscode . Uri [ ] > {
15
- return [ ] ;
17
+ const category = `&${ options . folder . query } &` . includes ( "&csp&" ) ? "CSP" : "*" ;
18
+ const generated = `&${ options . folder . query } &` . includes ( "&generated=1&" ) ;
19
+ const api = new AtelierAPI ( options . folder ) ;
20
+ let counter = 0 ;
21
+ if ( ! api . enabled ) {
22
+ return null ;
23
+ }
24
+ return api
25
+ . getDocNames ( {
26
+ filter : query . pattern ,
27
+ category,
28
+ generated,
29
+ } )
30
+ . then ( ( data ) => data . result . content )
31
+ . then ( ( files : DocSearchResult [ ] ) =>
32
+ files
33
+ . map ( ( file ) => {
34
+ if ( category === "*" && file . cat === "CSP" ) {
35
+ return null ;
36
+ }
37
+ if ( ! options . maxResults || ++ counter <= options . maxResults ) {
38
+ return options . folder . with ( { path : `/${ file . name } ` } ) ;
39
+ } else {
40
+ return null ;
41
+ }
42
+ } )
43
+ . filter ( ( el ) => el !== null )
44
+ ) ;
16
45
}
17
46
}
You can’t perform that action at this time.
0 commit comments