@@ -15,16 +15,10 @@ import {
15
15
} from '../../common/protocol' ;
16
16
import { BoardsConfig } from './boards-config' ;
17
17
import { naturalCompare } from '../../common/utils' ;
18
- import { compareAnything } from '../theia/monaco/comparers' ;
19
18
import { NotificationCenter } from '../notification-center' ;
20
19
import { CommandService } from '@theia/core' ;
21
20
import { ArduinoCommands } from '../arduino-commands' ;
22
21
23
- interface BoardMatch {
24
- readonly board : BoardWithPackage ;
25
- readonly matches : monaco . filters . IMatch [ ] | undefined ;
26
- }
27
-
28
22
@injectable ( )
29
23
export class BoardsServiceProvider implements FrontendApplicationContribution {
30
24
@@ -205,38 +199,9 @@ export class BoardsServiceProvider implements FrontendApplicationContribution {
205
199
}
206
200
}
207
201
208
- async searchBoards ( { query, cores } : { query ?: string , cores ?: string [ ] } ) : Promise < Array < BoardWithPackage > > {
209
- const boards = await this . boardsService . allBoards ( { } ) ;
210
- const coresFilter = ! ! cores && cores . length
211
- ? ( ( toFilter : BoardWithPackage ) => cores . some ( core => core === toFilter . packageName || core === toFilter . packageId ) )
212
- : ( ) => true ;
213
- if ( ! query ) {
214
- return boards . filter ( coresFilter ) . sort ( Board . compare ) ;
215
- }
216
- const toMatch = ( ( toFilter : BoardWithPackage ) => ( ( { board : toFilter , matches : monaco . filters . matchesFuzzy ( query , toFilter . name , true ) } ) ) ) ;
217
- const compareEntries = ( left : BoardMatch , right : BoardMatch , lookFor : string ) => {
218
- const leftMatches = left . matches || [ ] ;
219
- const rightMatches = right . matches || [ ] ;
220
- if ( leftMatches . length && ! rightMatches . length ) {
221
- return - 1 ;
222
- }
223
- if ( ! leftMatches . length && rightMatches . length ) {
224
- return 1 ;
225
- }
226
- if ( leftMatches . length === 0 && rightMatches . length === 0 ) {
227
- return 0 ;
228
- }
229
- const leftLabel = left . board . name . replace ( / \r ? \n / g, ' ' ) ;
230
- const rightLabel = right . board . name . replace ( / \r ? \n / g, ' ' ) ;
231
- return compareAnything ( leftLabel , rightLabel , lookFor ) ;
232
- }
233
- const normalizedQuery = query . toLowerCase ( ) ;
234
- return boards
235
- . filter ( coresFilter )
236
- . map ( toMatch )
237
- . filter ( ( { matches } ) => ! ! matches )
238
- . sort ( ( left , right ) => compareEntries ( left , right , normalizedQuery ) )
239
- . map ( ( { board } ) => board ) ;
202
+ async searchBoards ( { query, cores } : { query ?: string , cores ?: string [ ] } ) : Promise < BoardWithPackage [ ] > {
203
+ const boards = await this . boardsService . searchBoards ( { query } ) ;
204
+ return boards ;
240
205
}
241
206
242
207
get boardsConfig ( ) : BoardsConfig . Config {
0 commit comments