Was*_* A. 3 count caret string-length cursor-position ace-editor
是否存在任何函数或逻辑可以计算 ace 编辑器中光标当前位置(插入符号)之前的总字符数?
session.doc 上有positionToIndex 和indexToPosition 方法
editor.session.doc.positionToIndex(editor.selection.getCursor())
Run Code Online (Sandbox Code Playgroud)
请注意,这会迭代光标之前的所有行,因此对于某些用例来说可能会很慢。