Skip to content

Commit 7004c86

Browse files
committed
fix: update completion api
1 parent 874c244 commit 7004c86

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

addons/cli/src/main/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,11 +300,11 @@ ${
300300
commas.context.provide('cli.command', ...externalURLCommands)
301301
})
302302

303-
commas.context.provide('terminal.completion', async (query: string, command: string, subcommand?: string) => {
304-
if (command === 'commas' && !subcommand) {
303+
commas.context.provide('terminal.completion', async params => {
304+
if (params.command === 'commas' && !params.subcommand) {
305305
return commands.map(item => ({
306306
type: 'command' as const,
307-
query,
307+
query: params.query,
308308
value: item.command,
309309
description: [
310310
item.usage ? commas.i18n.translate(item.usage) : '',

src/api/main.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@ import type { CommandCompletion } from '@commas/types/terminal'
22

33
declare module './modules/context' {
44
export interface Context {
5-
'terminal.completion': (query: string, command: string, subcommand?: string) => Promise<CommandCompletion[]>,
5+
'terminal.completion': (params: {
6+
input: string,
7+
query: string,
8+
command: string,
9+
subcommand?: string,
10+
}) => Promise<CommandCompletion[]>,
611
}
712
}
813

src/main/utils/completion.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,12 @@ async function getCompletions(input: string, cwd: string) {
410410
// Registered
411411
const factories = commas.proxy.context.getCollection('terminal.completion')
412412
asyncCompletionLists = asyncCompletionLists.concat(
413-
factories.map(factory => factory(currentWord, command, subcommand)),
413+
factories.map(factory => factory({
414+
input,
415+
query: currentWord,
416+
command,
417+
subcommand,
418+
})),
414419
)
415420
// History
416421
if (currentWord) {

0 commit comments

Comments
 (0)