Skip to content

TextEditorDocument.findMatches ranges off by one #9106

Open
@colin-grant-work

Description

Bug Description:

The matches returned by the findMatches method of a TextEditorDocument are off by one (higher on each axis) relative to the selection behavior of an editor widget.

Using this code:

            const editorWidget = await this.editorManager.getOrCreateByUri(tasksJSONUri);
            const range = editorWidget.editor.document.findMatches?.({
                searchString: '"should highlight this"',
                isRegex: false,
                matchCase: true,
                matchWholeWord: false,
                limitResultCount: 1,
            })[0]?.range;

            this.editorManager.open(tasksJSONUri, { selection: range });

I expected the string "should highlight this" to be highlighted, but instead I got this:

image

Steps to Reproduce:

  1. Create a text document with at least two lines and some text on each line.
  2. Access the editor programmatically and use findMatches as illustrated above.
  3. Open the editor with a {selection} or open the editor and set editor.selection = range
  4. Observe that the wrong line is highlighted, and the highlighting is one character to the right of where it should be.

Additional Information

  • Operating System: RHEL, browser mode (Chrome)
  • Theia Version: 1.10.0

Metadata

Assignees

No one assigned

    Labels

    monacoissues related to monaco

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions