在Monaco编辑器中,如何从IEditor界面获取选中的文本

In the Monaco editor, how do I get the selected text from the IEditor interface

迷失在 API 的电报文档中。如何从 IEditor 界面获取选中的文本? getSelection返回的selection对象只有行号和列号。然后我需要在编辑器的文本中搜索文本吗?

并且,与 getSelections 返回的所有其他选择相比,主要选择是什么?

相当多的 monaco 编辑器 API 使用范围或跨度。使用范围,您可以获得 editor.getModel().getValueInRange().

范围内的文本

关于多个 selection:monaco-editor 支持多个 selection。你首先 select 一些没有修饰键的文本,它成为主要的 selection。然后通过按住 altopt 在 macOS 上)同时拖动新范围来添加次级 selection。