mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-06-08 14:34:13 +08:00
提示去重
This commit is contained in:
parent
468600971e
commit
7c32de1bbc
@ -30,19 +30,21 @@
|
|||||||
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
|
||||||
anyword.forEach(a => {
|
anyword.forEach(a => {
|
||||||
if (!hints.includes(a)) hints.push(a)
|
if (!hints.includes(a)) hints.push(a)
|
||||||
})
|
})
|
||||||
return {
|
return {
|
||||||
list: hints,
|
list: hints,
|
||||||
from: CodeMirror.Pos(cur.line, token.start),
|
from: CodeMirror.Pos(cur.line, token.start),
|
||||||
@ -171,4 +173,4 @@
|
|||||||
// http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types
|
// http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types
|
||||||
CodeMirror.defineMIME('application/x-sh', 'cmd');
|
CodeMirror.defineMIME('application/x-sh', 'cmd');
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -32,19 +32,21 @@
|
|||||||
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
|
||||||
anyword.forEach(a => {
|
anyword.forEach(a => {
|
||||||
if (!hints.includes(a)) hints.push(a)
|
if (!hints.includes(a)) hints.push(a)
|
||||||
})
|
})
|
||||||
return {
|
return {
|
||||||
list: hints,
|
list: hints,
|
||||||
from: CodeMirror.Pos(cur.line, token.start),
|
from: CodeMirror.Pos(cur.line, token.start),
|
||||||
@ -171,4 +173,4 @@
|
|||||||
// http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types
|
// http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types
|
||||||
CodeMirror.defineMIME('application/x-sh', 'shell');
|
CodeMirror.defineMIME('application/x-sh', 'shell');
|
||||||
|
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user