TextEditorDocument.findMatches ranges off by one #9106
Open
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:
Steps to Reproduce:
- Create a text document with at least two lines and some text on each line.
- Access the editor programmatically and use
findMatches
as illustrated above. - Open the editor with a
{selection}
or open the editor and seteditor.selection = range
- 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