Skip to content

Commit

Permalink
feat: display custom client-side commands in completions
Browse files Browse the repository at this point in the history
  • Loading branch information
zardoy committed Sep 23, 2023
1 parent 38d1a58 commit 09a9550
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/builtinCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ const commands = [
}
]

export const getBuiltinCommandsList = () => commands.flatMap(command => command.command)

export const tryHandleBuiltinCommand = (message) => {
if (!localServer) return

Expand Down
4 changes: 3 additions & 1 deletion src/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const { activeModalStack, hideCurrentModal, showModal, miscUiState } = require('
import { repeat } from 'lit/directives/repeat.js'
import { classMap } from 'lit/directives/class-map.js'
import { isCypress } from './utils'
import { tryHandleBuiltinCommand } from './builtinCommands'
import { getBuiltinCommandsList, tryHandleBuiltinCommand } from './builtinCommands'
import { notification } from './menus/notification'
import { options } from './optionsStorage'

Expand Down Expand Up @@ -488,6 +488,7 @@ class ChatBox extends LitElement {
}

async fetchCompletion (value = this.getCompleteValue()) {
this.completionItemsSource = []
this.completionItems = []
this.completeRequestValue = value
let items = await bot.tabComplete(value, true, true)
Expand All @@ -496,6 +497,7 @@ class ChatBox extends LitElement {
if (items[0].match) items = items.map(i => i.match)
}
if (value !== this.completeRequestValue) return
if (this.completeRequestValue === '/') items = [...items, ...getBuiltinCommandsList()]
this.completionItems = items
this.completionItemsSource = items
}
Expand Down

0 comments on commit 09a9550

Please sign in to comment.