Commit 77b4b5b1 by pangchong

feat: 防止选中后重新唤起

parent 1bb9b364
...@@ -469,7 +469,8 @@ const xmlCompletionSource = (context: CompletionContext) => { ...@@ -469,7 +469,8 @@ const xmlCompletionSource = (context: CompletionContext) => {
return { return {
from: context.pos - typedAttr.length, from: context.pos - typedAttr.length,
options options,
validFor: /^[a-zA-Z0-9_-]*$/
} }
} }
} else { } else {
...@@ -489,6 +490,13 @@ const xmlCompletionSource = (context: CompletionContext) => { ...@@ -489,6 +490,13 @@ const xmlCompletionSource = (context: CompletionContext) => {
const attrDef = attrs[attrName] const attrDef = attrs[attrName]
if (attrDef && attrDef.enumValues && attrDef.enumValues.length > 0) { if (attrDef && attrDef.enumValues && attrDef.enumValues.length > 0) {
const typedVal = tagText.substring(lastQuoteIdx + 1) const typedVal = tagText.substring(lastQuoteIdx + 1)
// 如果非显式快捷键唤起(自动补全),且当前已完整匹配其中一个属性值候选,则无需弹窗提示
const isExactMatch = attrDef.enumValues.some((val) => val.toLowerCase() === typedVal.toLowerCase())
if (!context.explicit && isExactMatch) {
return null
}
const options = attrDef.enumValues.map((val) => { const options = attrDef.enumValues.map((val) => {
return { return {
label: val, label: val,
...@@ -500,7 +508,8 @@ const xmlCompletionSource = (context: CompletionContext) => { ...@@ -500,7 +508,8 @@ const xmlCompletionSource = (context: CompletionContext) => {
return { return {
from: context.pos - typedVal.length, from: context.pos - typedVal.length,
options options,
validFor: /^[a-zA-Z0-9_-]*$/
} }
} }
} }
...@@ -644,7 +653,10 @@ const initCodeMirror = () => { ...@@ -644,7 +653,10 @@ const initCodeMirror = () => {
} }
// 如果是用户编辑(输入或删除)导致的变化,且当前正处于可能需要提示的上下文中,自动激活提示 // 如果是用户编辑(输入或删除)导致的变化,且当前正处于可能需要提示的上下文中,自动激活提示
const isUserEdit = update.transactions.some((tr) => tr.isUserEvent('input') || tr.isUserEvent('delete')) // 注意:如果是通过下拉列表选中补全项(input.complete),则不再重新唤起 startCompletion
const isUserEdit = update.transactions.some(
(tr) => (tr.isUserEvent('input') || tr.isUserEvent('delete')) && !tr.isUserEvent('input.complete')
)
if (isUserEdit) { if (isUserEdit) {
const mainSelection = update.state.selection.main const mainSelection = update.state.selection.main
if (mainSelection.empty) { if (mainSelection.empty) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment