如何在Monaco编辑器中以编程方式查找文本的位置

问题描述 投票:0回答:1

有没有办法如何通过原始字符串和字符串中子字符串的开头和结尾的索引来计算摩纳哥编辑器中的位置?

find matches API有可能:

editor.getModel().findMatches('sub_string')

我想知道是否有任何其他方式,因为可以有多个匹配,API方法不完全适合我当前的任务。

monaco-editor
1个回答
0
投票

有一个API方法getPositionAt(见here

const position = editor.getModel().getPositionAt(index);
const { lineNumber, column } = position;
© www.soinside.com 2019 - 2024. All rights reserved.