为什么ace编辑器不发出tokenizerUpdate事件

问题描述

我在compositionComplete()

中有此代码
this.docEditor = aceEditorBindingHandler.getEditorBySelection($(docEditorSelector);
// this.docEditor is of type AceAjax.Editor

if (this.docEditor) {
        this.docEditor.getSession().on("tokenizerUpdate",() => {
            // do stuff
        });
    }

但没有从不命中。

如果我将事件更改为在“ change”上,则内容更改时将命中代码。
但这不是我所需要的。

有什么主意吗?有人吗?

解决方法

与更改事件不同,未同步调用令牌生成器更新。请参见下面的示例以演示其工作。

<script src=https://ajaxorg.github.io/ace-builds/src-noconflict/ace.js></script>

<script>
  editor = ace.edit(null,{
    mode: "ace/mode/javascript",minLines: 5,maxLines: 10,})
  var log = ace.edit(null,})

  document.documentElement.appendChild(editor.container)
  document.documentElement.appendChild(log.container)
  editor.session.on("tokenizerUpdate",() => {
    log.insert("tokenizerUpdate called " + Date.now() + "\n")
  })
</script>

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...