From 0c6accae8b019771bd4a5e4beb993df4fc3d322a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E4=BC=9F=E5=BC=BA?= Date: Tue, 23 May 2023 07:48:32 +0000 Subject: [PATCH] =?UTF-8?q?!2224=20=E4=BF=AE=E5=A4=8D=EF=BC=9A=E6=84=9F?= =?UTF-8?q?=E7=9F=A5=E5=88=97=E8=A1=A8=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/DatabaseServices/CommandServer.ts | 4 -- src/UI/Components/Board/ConfigTagCommand.ts | 2 +- .../Components/commandLineInput/InputHint.tsx | 49 +++++++++---------- 3 files changed, 24 insertions(+), 31 deletions(-) diff --git a/src/DatabaseServices/CommandServer.ts b/src/DatabaseServices/CommandServer.ts index 5702e80f6..350b84441 100644 --- a/src/DatabaseServices/CommandServer.ts +++ b/src/DatabaseServices/CommandServer.ts @@ -223,10 +223,6 @@ export class CommandServer this._CustomCommandMap.set(customCmd, cmd);//注册自定义命令 this._CommandCustomMap.set(cmd, customCmd); - if (commandMachine.CommandNameSet.has(cmd)) - { - commandMachine.CommandNameSet.delete(cmd); - } commandMachine.CommandNameSet.add(customCmd); } diff --git a/src/UI/Components/Board/ConfigTagCommand.ts b/src/UI/Components/Board/ConfigTagCommand.ts index b50307efe..a8a53f624 100644 --- a/src/UI/Components/Board/ConfigTagCommand.ts +++ b/src/UI/Components/Board/ConfigTagCommand.ts @@ -130,7 +130,7 @@ export class ConfigTagCommand { this._CustomTagCommandMap.set(tag.tagName, { cmdName: this._ConfigTagCommandMap.get(tag.type), configName: tag.configName, type: tag.type }); //注册自定义命令 commandMachine.CommandNameSet.add(tag.tagName); - commandMachine.CommandSet.add({command:tag.tagName, chName:tag.configName}) + commandMachine.CommandSet.add({ command: tag.tagName }); } } diff --git a/src/UI/Components/commandLineInput/InputHint.tsx b/src/UI/Components/commandLineInput/InputHint.tsx index 5adf72dca..9d102952d 100644 --- a/src/UI/Components/commandLineInput/InputHint.tsx +++ b/src/UI/Components/commandLineInput/InputHint.tsx @@ -14,7 +14,7 @@ import { commandMachine } from '../../../Editor/CommandMachine'; import { CommandState } from '../../../Editor/CommandState'; import { CommandStore } from '../../Store/CommandStore'; import { CommandInputHeight } from '../CommandInput/CommandInputUI'; -import { ICommand } from "../CommandPanel/CommandList"; +import { CommandList, ICommand } from "../CommandPanel/CommandList"; import { SwitchServerStore } from '../Modal/SwitchServerStore'; import './InputHint.css'; @@ -34,7 +34,7 @@ interface InputHitState { isShowHistory: boolean;//显示历史命令 intelliSenseIndex: number;//感知的当前选择位置 - intelliSenseCommand: Array;//感知命令列表 + intelliSenseCommand: Array>;//感知命令列表 topToolBarHeight: number; //顶部标签栏高度 } @@ -147,34 +147,31 @@ export class InputHint extends React.Component const commandObjList = Array.from(commandMachine.CommandSet); - const verifyChNameBelongCommand = (cmdName: string, inputCmd: string) => - { - const item = commandObjList.find((v) => v.defaultCustom === cmdName || v.command === cmdName || v.customize === cmdName); - if (item && ((item.chName && item.chName.indexOf(inputCmd) !== -1) || item.command.indexOf(inputCmd) !== -1)) - intelliSenseCmdList.push(item.command || cmdName); - }; - let intelliSenseCmdList: string[] = []; - for (let cmdName of commandMachine.CommandNameSet) + if (isChinese(inputCmd))// { - try + for (let cmd of CommandList) + if (cmd.chName.indexOf(inputCmd) !== -1) + intelliSenseCmdList.push(cmd.command); + } + else + for (let cmdName of commandMachine.CommandNameSet) { - //修改后感知列表顺序会改变 - if (inputCmd.length === 1) + try { - if (cmdName.indexOf(inputCmd) === 0) + if (inputCmd.length === 1) + { + if (cmdName.indexOf(inputCmd) === 0) + intelliSenseCmdList.push(cmdName); + } + else if (cmdName.indexOf(inputCmd) !== -1 || searchReg.test(cmdName)) intelliSenseCmdList.push(cmdName); - else verifyChNameBelongCommand(cmdName, inputCmd); + } catch (error) + { + Log("正则表达式测试错误!", LogType.Error); } - else if (cmdName.indexOf(inputCmd) !== -1 || searchReg.test(cmdName)) - intelliSenseCmdList.push(cmdName); - else verifyChNameBelongCommand(cmdName, inputCmd); - } catch (error) - { - Log("正则表达式测试错误!", LogType.Error); } - } intelliSenseCmdList.sort((c1, c2) => { @@ -195,17 +192,17 @@ export class InputHint extends React.Component return c1.length < c2.length ? -1 : 1; }); - const cmdList = []; + const cmdList = new Set>(); for (let cmd of intelliSenseCmdList) { const item = commandObjList.find((v) => v.defaultCustom === cmd || v.command === cmd || v.customize === cmd); if (item) - cmdList.push(item); + cmdList.add(item); else - cmdList.push({ command: cmd }); + cmdList.add({ command: cmd }); } this.setState({ - intelliSenseCommand: cmdList, + intelliSenseCommand: Array.from(cmdList), intelliSenseIndex: 0 }); }