MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / update

Method update

src/cm/lsp/tooltipExtensions.ts:591–656  ·  view source on GitHub ↗
(update: ViewUpdate)

Source from the content-addressed store, hash-verified

589 constructor(readonly view: EditorView) {}
590
591 update(update: ViewUpdate) {
592 const pointerOrTouchSelection = isPointerOrTouchSelection(update);
593
594 if (this.activeRequest) {
595 if (update.selectionSet) {
596 this.activeRequest.drop = true;
597 this.activeRequest = null;
598 } else if (update.docChanged) {
599 this.activeRequest.pos = update.changes.mapPos(
600 this.activeRequest.pos,
601 );
602 }
603 }
604
605 const plugin = LSPPlugin.get(update.view);
606 if (!plugin) return;
607
608 const sigState = update.view.state.field(signatureState);
609 let triggerCharacter = "";
610
611 if (
612 update.docChanged &&
613 update.transactions.some((tr) => tr.isUserEvent("input.type"))
614 ) {
615 const serverConf =
616 plugin.client.serverCapabilities?.signatureHelpProvider;
617 const triggers = (serverConf?.triggerCharacters || []).concat(
618 (sigState && serverConf?.retriggerCharacters) || [],
619 );
620
621 if (triggers.length) {
622 update.changes.iterChanges((_fromA, _toA, _fromB, _toB, inserted) => {
623 const insertedText = inserted.toString();
624 if (!insertedText) return;
625 for (const trigger of triggers) {
626 if (insertedText.includes(trigger)) {
627 triggerCharacter = trigger;
628 }
629 }
630 });
631 }
632 }
633
634 if (triggerCharacter) {
635 this.scheduleRequest(
636 plugin,
637 {
638 triggerKind: 2,
639 isRetrigger: !!sigState,
640 triggerCharacter,
641 activeSignatureHelp: sigState?.data,
642 },
643 SIGNATURE_TRIGGER_DELAY,
644 );
645 } else if (sigState && update.selectionSet && !pointerOrTouchSelection) {
646 this.scheduleRequest(
647 plugin,
648 {

Callers

nothing calls this directly

Calls 4

scheduleRequestMethod · 0.80
getMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected