Skip to content

visual editor: support multi-cursor 'add next match' in the find API #1103

Description

@kevinushey

Context

RStudio's "Find and Add Next" and "Find All" commands build a multi-cursor selection from the current find match (Ace's "add next selection" feature). In the visual editor these commands work inside code chunks (routed to the chunk's embedded Ace editor, rstudio/rstudio#18651), but they cannot work in prose: the editor's find API only exposes single-selection operations, so RStudio currently reports the commands as disabled there.

Reported by users in rstudio/rstudio#16540, where the repro is specifically prose.

Feature request

An "add next match to selection" capability (and ideally a companion "select all matches") in the editor's find API, so embedders can offer multi-cursor style editing over find results in prose.

Technical notes

  • EditorFindReplace (packages/editor/src/editor/editor.ts, exposed via Editor.getFindReplace()) currently exposes selectFirst / selectCurrent / selectNext / selectPrevious / replace / replaceAll, all single-selection, backed by the FindPlugin in packages/editor/src/behaviors/find.ts.
  • ProseMirror's TextSelection is a single range and multi-range selection is not a native concept, so this likely requires either a custom Selection subclass or a plugin that maintains the additional ranges as decorations and fans typed edits out to every range.

Not a small change -- filing so the request is tracked upstream and can be prioritized. Happy to discuss design or contribute if there's an agreed direction.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions