fix: autocomplete env bug
This commit is contained in:
@@ -93,6 +93,7 @@ import IconEyeoff from "~icons/lucide/eye-off"
|
|||||||
import { CompletionContext, autocompletion } from "@codemirror/autocomplete"
|
import { CompletionContext, autocompletion } from "@codemirror/autocomplete"
|
||||||
import { useService } from "dioc/vue"
|
import { useService } from "dioc/vue"
|
||||||
import { RESTTabService } from "~/services/tab/rest"
|
import { RESTTabService } from "~/services/tab/rest"
|
||||||
|
import { syntaxTree } from "@codemirror/language"
|
||||||
|
|
||||||
const t = useI18n()
|
const t = useI18n()
|
||||||
|
|
||||||
@@ -405,16 +406,14 @@ function envAutoCompletion(context: CompletionContext) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
: []
|
: []
|
||||||
|
const nodeBefore = syntaxTree(context.state).resolveInner(context.pos, -1)
|
||||||
const textBefore = context.state.sliceDoc(context.pos - 2, context.pos)
|
const textBefore = context.state.sliceDoc(nodeBefore.from, context.pos)
|
||||||
|
const tagBefore = /<<\w*$/.exec(textBefore)
|
||||||
const tagBefore = /<<\w*/.exec(textBefore)
|
if (!tagBefore && !context.explicit) return null
|
||||||
|
|
||||||
if (!tagBefore) return null
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
from: context.pos - 2,
|
from: tagBefore ? nodeBefore.from + tagBefore.index : context.pos,
|
||||||
options: options,
|
options: options,
|
||||||
|
validFor: /^(<<\w*)?$/,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user