Skip to content

Double workflow/search triggered after selection in strategy matching (version 0.1.13) #363

@R0lin

Description

@R0lin

Title

Double workflow/search triggered after selection in strategy matching (version 0.1.13)

Environment

  • @textcomplete/core version: 0.1.13
  • @textcomplete/textarea version: 0.1.13
  • Basic setup without any additional configuration.

Minimal Repro Code

import { TextareaEditor } from '@textcomplete/textarea';
import { Textcomplete } from '@textcomplete/core';

const textarea = document.getElementById('editor');
const editor = new TextareaEditor(textarea);

const strategies = [{
  id: 'strategyA',
  match: /\\#$/,
  context: (beforeCursor) => {
    console.log('[Strategy A] workflow started with: ' + beforeCursor);
    return true;
  },
  search: (term, callback) => {
    console.log('[Strategy A] search:' + term);
    callback([{ title: 'Local', text: 'L' }]);
  },
  template: (item) => `<div>${item.title} (${item.text})</div>`,
  replace: () => '#L:'
}];

const textcomplete = new Textcomplete(editor, strategies);

Steps to Reproduce

  1. Type # into the textarea → dropdown appears.
  2. Observe logs:
[Strategy A] workflow started with: #
[Strategy A] search:undefined
  1. Select the suggestion → the textarea becomes #L:
  2. Observe logs again:
[Strategy A] workflow started with: #L:
[Strategy A] workflow started with: #L:

Expected Behavior

Only one search/workflow cycle should run after the suggestion selection.

Actual Behavior

Search/workflow is triggered twice — duplicate logs after replacement.

Sandbox

Problem Sample Sandbox link

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions