提示去重

This commit is contained in:
fofolee 2020-07-14 20:51:35 +08:00
parent 468600971e
commit 7c32de1bbc
2 changed files with 16 additions and 12 deletions

View File

@ -30,13 +30,15 @@
token = editor.getTokenAt(cur); token = editor.getTokenAt(cur);
if (token.string == "") return if (token.string == "") return
// 关键字提示 // 关键字提示
var hints = commonAtoms.concat(commonKeywords, commonCommands) var hints = [], tokenstring = token.string.toUpperCase()
var localCommands = JSON.parse(localStorage['cmdCommands']).filter(x => !hints.includes(x)) var localCommands = JSON.parse(localStorage['cmdCommands'])
hints = hints.concat(localCommands).filter(x => x.slice(0, token.string.length) == token.string) commonAtoms.concat(commonKeywords, commonCommands, localCommands).forEach(x => {
if (x.toUpperCase().slice(0, token.string.length) == tokenstring && !hints.includes(x)) hints.push(x)
})
// 特殊变量提示 // 特殊变量提示
var specialVars = localStorage['specialVars'] var specialVars = localStorage['specialVars']
if (specialVars) specialVars.split(',').forEach(s => { if (specialVars) specialVars.split(',').forEach(s => {
if (s.toUpperCase().slice(2, token.string.length + 2) == token.string.toUpperCase()) hints.push(s) if (s.toUpperCase().slice(2, token.string.length + 2) == tokenstring) hints.push(s)
}) })
// 本地单词提示 // 本地单词提示
var anyword = CodeMirror.hint.anyword(editor, options).list var anyword = CodeMirror.hint.anyword(editor, options).list

View File

@ -32,13 +32,15 @@
token = editor.getTokenAt(cur); token = editor.getTokenAt(cur);
if (token.string == "") return if (token.string == "") return
// 关键字提示 // 关键字提示
var hints = commonAtoms.concat(commonKeywords, commonCommands) var hints = [], tokenstring = token.string.toUpperCase()
var localCommands = JSON.parse(localStorage['shellCommands']).filter(x => !hints.includes(x)) var localCommands = JSON.parse(localStorage['shellCommands'])
hints = hints.concat(localCommands).filter(x => x.slice(0, token.string.length) == token.string) commonAtoms.concat(commonKeywords, commonCommands, localCommands).forEach(x => {
if (x.toUpperCase().slice(0, token.string.length) == tokenstring && !hints.includes(x)) hints.push(x)
})
// 特殊变量提示 // 特殊变量提示
var specialVars = localStorage['specialVars'] var specialVars = localStorage['specialVars']
if (specialVars) specialVars.split(',').forEach(s => { if (specialVars) specialVars.split(',').forEach(s => {
if (s.toUpperCase().slice(2, token.string.length + 2) == token.string.toUpperCase()) hints.push(s) if (s.toUpperCase().slice(2, token.string.length + 2) == tokenstring) hints.push(s)
}) })
// 本地单词提示 // 本地单词提示
var anyword = CodeMirror.hint.anyword(editor, options).list var anyword = CodeMirror.hint.anyword(editor, options).list