Skip to content

Commit 716ebcd

Browse files
committed
feat: display custom client-side commands in completions
1 parent 6283d9b commit 716ebcd

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/builtinCommands.ts

+2
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ const commands = [
9696
}
9797
]
9898

99+
export const getBuiltinCommandsList = () => commands.flatMap(command => command.command)
100+
99101
export const tryHandleBuiltinCommand = (message) => {
100102
if (!localServer) return
101103

src/chat.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const { activeModalStack, hideCurrentModal, showModal, miscUiState } = require('
55
import { repeat } from 'lit/directives/repeat.js'
66
import { classMap } from 'lit/directives/class-map.js'
77
import { isCypress } from './utils'
8-
import { tryHandleBuiltinCommand } from './builtinCommands'
8+
import { getBuiltinCommandsList, tryHandleBuiltinCommand } from './builtinCommands'
99
import { notification } from './menus/notification'
1010
import { options } from './optionsStorage'
1111

@@ -488,6 +488,7 @@ class ChatBox extends LitElement {
488488
}
489489

490490
async fetchCompletion (value = this.getCompleteValue()) {
491+
this.completionItemsSource = []
491492
this.completionItems = []
492493
this.completeRequestValue = value
493494
let items = await bot.tabComplete(value, true, true)
@@ -496,6 +497,7 @@ class ChatBox extends LitElement {
496497
if (items[0].match) items = items.map(i => i.match)
497498
}
498499
if (value !== this.completeRequestValue) return
500+
if (this.completeRequestValue === '/') items = [...items, ...getBuiltinCommandsList()]
499501
this.completionItems = items
500502
this.completionItemsSource = items
501503
}

0 commit comments

Comments
 (0)