(ctx: CompletionContext)
| 437 | }); |
| 438 | |
| 439 | const watCompletionSource = (ctx: CompletionContext): CompletionResult | null => { |
| 440 | try { |
| 441 | const text = ctx.state.doc.toString(); |
| 442 | if (!isWatContent(text)) return null; |
| 443 | |
| 444 | const word = ctx.matchBefore(/[\w$]+/); |
| 445 | const afterDot = ctx.matchBefore(/\.\w*$/); |
| 446 | if (!ctx.explicit && !word && !afterDot) return null; |
| 447 | |
| 448 | const line = ctx.state.doc.lineAt(ctx.pos); |
| 449 | parseIfNeeded(text); |
| 450 | const items = lsp.provideCompletion(line.number - 1, ctx.pos - line.from); |
| 451 | if (!items.length) return null; |
| 452 | |
| 453 | const from = word ? word.from : ctx.pos; |
| 454 | return { |
| 455 | from, |
| 456 | options: items.map((item) => ({ |
| 457 | label: item.label, |
| 458 | apply: item.insertText ?? item.label, |
| 459 | ...(item.detail != null && { detail: item.detail }), |
| 460 | ...(item.documentation != null && { info: item.documentation }), |
| 461 | })), |
| 462 | }; |
| 463 | } catch { |
| 464 | return null; |
| 465 | } |
| 466 | }; |
| 467 | |
| 468 | // Cmd/Ctrl+click for go-to-definition |
| 469 | const clickGoToDef = EditorView.domEventHandlers({ |
nothing calls this directly
no test coverage detected