File tree Expand file tree Collapse file tree 2 files changed +9
-6
lines changed
Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -41,13 +41,16 @@ interface ChatCommands {
4141 del ?: Command ;
4242}
4343
44- export const ChatCommandPrefix = ":" ;
44+ // Compatible with Chinese colon character ":"
45+ export const ChatCommandPrefix = / ^ [: : ] / ;
4546
4647export function useChatCommand ( commands : ChatCommands = { } ) {
4748 function extract ( userInput : string ) {
48- return (
49- userInput . startsWith ( ChatCommandPrefix ) ? userInput . slice ( 1 ) : userInput
50- ) as keyof ChatCommands ;
49+ const match = userInput . match ( ChatCommandPrefix ) ;
50+ if ( match ) {
51+ return userInput . slice ( 1 ) as keyof ChatCommands ;
52+ }
53+ return userInput as keyof ChatCommands ;
5154 }
5255
5356 function search ( userInput : string ) {
@@ -57,7 +60,7 @@ export function useChatCommand(commands: ChatCommands = {}) {
5760 . filter ( ( c ) => c . startsWith ( input ) )
5861 . map ( ( c ) => ( {
5962 title : desc [ c as keyof ChatCommands ] ,
60- content : ChatCommandPrefix + c ,
63+ content : ":" + c ,
6164 } ) ) ;
6265 }
6366
Original file line number Diff line number Diff line change @@ -811,7 +811,7 @@ function _Chat() {
811811 // clear search results
812812 if ( n === 0 ) {
813813 setPromptHints ( [ ] ) ;
814- } else if ( text . startsWith ( ChatCommandPrefix ) ) {
814+ } else if ( text . match ( ChatCommandPrefix ) ) {
815815 setPromptHints ( chatCommands . search ( text ) ) ;
816816 } else if ( ! config . disablePromptHint && n < SEARCH_TEXT_LIMIT ) {
817817 // check if need to trigger auto completion
You can’t perform that action at this time.
0 commit comments