diff --git a/src/UI/Components/commandLineInput/InputHint.tsx b/src/UI/Components/commandLineInput/InputHint.tsx index 84533f72b..f8f221c0b 100644 --- a/src/UI/Components/commandLineInput/InputHint.tsx +++ b/src/UI/Components/commandLineInput/InputHint.tsx @@ -5,6 +5,7 @@ import { end } from 'xaop'; import { app } from '../../../ApplicationServices/Application'; import { KeyWord } from '../../../Common/InputState'; import { KeyBoard } from '../../../Common/KeyEnum'; +import { Log } from '../../../Common/Log'; import { FixIndex, isLetter, isNum } from '../../../Common/Utils'; import { CommandState } from '../../../Editor/CommandState'; import { CommandStore } from '../../Store/CommandStore'; @@ -33,7 +34,7 @@ interface InputHitState } /** - * + * */ @observer export class InputHint extends React.Component @@ -101,20 +102,33 @@ export class InputHint extends React.Component let searchReg: RegExp; // 拼接动态正则表达式 let m_comTmp: string = '^' + inputCmd.split('').join('\\w*') + '\\w*$'; - searchReg = new RegExp(m_comTmp, 'i'); + try + { + searchReg = new RegExp(m_comTmp, 'i'); + } catch (error) + { + Log("正则表达式构建错误!"); + return; + } let intelliSenseCmdList: string[] = []; for (let cmdName of this.props.cmdList) { - 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 if (cmdName.indexOf(inputCmd) !== -1 - || searchReg.test(cmdName)) + } + } catch (error) { - intelliSenseCmdList.push(cmdName); + Log("正则表达式测试错误!"); } } intelliSenseCmdList.sort((c1, c2) =>