Skip to content

Commit 15b0564

Browse files
Akos Kittakittaakos
Akos Kitta
authored andcommitted
ATL-974: Use board search command from the CLI
Signed-off-by: Akos Kitta <[email protected]>
1 parent e90fa27 commit 15b0564

File tree

8 files changed

+35
-745
lines changed

8 files changed

+35
-745
lines changed

Diff for: arduino-ide-extension/package.json

+1-4
Original file line numberDiff line numberDiff line change
@@ -115,16 +115,13 @@
115115
"frontend": "lib/browser/theia/core/browser-menu-module",
116116
"frontendElectron": "lib/electron-browser/theia/core/electron-menu-module"
117117
},
118-
{
119-
"frontend": "lib/browser/boards/quick-open/boards-quick-open-module"
120-
},
121118
{
122119
"electronMain": "lib/electron-main/arduino-electron-main-module"
123120
}
124121
],
125122
"arduino": {
126123
"cli": {
127-
"version": "20210315"
124+
"version": "20210317"
128125
}
129126
}
130127
}

Diff for: arduino-ide-extension/src/browser/boards/boards-service-provider.ts

+3-38
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,10 @@ import {
1515
} from '../../common/protocol';
1616
import { BoardsConfig } from './boards-config';
1717
import { naturalCompare } from '../../common/utils';
18-
import { compareAnything } from '../theia/monaco/comparers';
1918
import { NotificationCenter } from '../notification-center';
2019
import { CommandService } from '@theia/core';
2120
import { ArduinoCommands } from '../arduino-commands';
2221

23-
interface BoardMatch {
24-
readonly board: BoardWithPackage;
25-
readonly matches: monaco.filters.IMatch[] | undefined;
26-
}
27-
2822
@injectable()
2923
export class BoardsServiceProvider implements FrontendApplicationContribution {
3024

@@ -205,38 +199,9 @@ export class BoardsServiceProvider implements FrontendApplicationContribution {
205199
}
206200
}
207201

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;
240205
}
241206

242207
get boardsConfig(): BoardsConfig.Config {

Diff for: arduino-ide-extension/src/browser/boards/quick-open/boards-quick-open-module.ts

-16
This file was deleted.

0 commit comments

Comments
 (0)