fix: autocompletion position messing up
This commit is contained in:
@@ -4,7 +4,7 @@ import { getAutocompleteSuggestions } from "graphql-language-service-interface"
|
||||
import { Completer, CompleterResult, CompletionEntry } from "."
|
||||
|
||||
const completer: (schemaRef: Ref<GraphQLSchema | null>) => Completer =
|
||||
(schemaRef: Ref<GraphQLSchema | null>) => (text, completePos, tokenPos) => {
|
||||
(schemaRef: Ref<GraphQLSchema | null>) => (text, completePos) => {
|
||||
if (!schemaRef.value) return Promise.resolve(null)
|
||||
|
||||
const completions = getAutocompleteSuggestions(schemaRef.value, text, {
|
||||
@@ -13,8 +13,6 @@ const completer: (schemaRef: Ref<GraphQLSchema | null>) => Completer =
|
||||
} as any)
|
||||
|
||||
return Promise.resolve(<CompleterResult>{
|
||||
start: tokenPos.start,
|
||||
end: tokenPos.end,
|
||||
completions: completions.map(
|
||||
(x, i) =>
|
||||
<CompletionEntry>{
|
||||
|
||||
@@ -9,16 +9,6 @@ export type CompleterResult = {
|
||||
* List of completions to display
|
||||
*/
|
||||
completions: CompletionEntry[]
|
||||
/**
|
||||
* Start of the completion position
|
||||
* (on completion the start..end region is replaced)
|
||||
*/
|
||||
start: { line: number; ch: number }
|
||||
/**
|
||||
* End of the completion position
|
||||
* (on completion the start..end region is replaced)
|
||||
*/
|
||||
end: { line: number; ch: number }
|
||||
}
|
||||
|
||||
export type Completer = (
|
||||
@@ -29,9 +19,5 @@ export type Completer = (
|
||||
/**
|
||||
* Position where the completer is fired
|
||||
*/
|
||||
completePos: { line: number; ch: number },
|
||||
completeTokenLocation: {
|
||||
start: { line: number; ch: number }
|
||||
end: { line: number; ch: number }
|
||||
}
|
||||
completePos: { line: number; ch: number }
|
||||
) => Promise<CompleterResult | null>
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { convertIndexToLineCh } from "../utils"
|
||||
import { Completer, CompletionEntry } from "."
|
||||
import { getPreRequestScriptCompletions } from "~/helpers/tern"
|
||||
|
||||
@@ -9,9 +8,6 @@ const completer: Completer = async (text, completePos) => {
|
||||
completePos.ch
|
||||
)
|
||||
|
||||
const start = convertIndexToLineCh(text, results.start)
|
||||
const end = convertIndexToLineCh(text, results.end)
|
||||
|
||||
const completions = results.completions.map((completion: any, i: number) => {
|
||||
return <CompletionEntry>{
|
||||
text: completion.name,
|
||||
@@ -21,8 +17,6 @@ const completer: Completer = async (text, completePos) => {
|
||||
})
|
||||
|
||||
return {
|
||||
start,
|
||||
end,
|
||||
completions,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { convertIndexToLineCh } from "../utils"
|
||||
import { Completer, CompletionEntry } from "."
|
||||
import { getTestScriptCompletions } from "~/helpers/tern"
|
||||
|
||||
@@ -9,9 +8,6 @@ export const completer: Completer = async (text, completePos) => {
|
||||
completePos.ch
|
||||
)
|
||||
|
||||
const start = convertIndexToLineCh(text, results.start)
|
||||
const end = convertIndexToLineCh(text, results.end)
|
||||
|
||||
const completions = results.completions.map((completion: any, i: number) => {
|
||||
return <CompletionEntry>{
|
||||
text: completion.name,
|
||||
@@ -21,8 +17,6 @@ export const completer: Completer = async (text, completePos) => {
|
||||
})
|
||||
|
||||
return {
|
||||
start,
|
||||
end,
|
||||
completions,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user