为什么ace编辑器加载所有高亮显示的文本以及如何将其删除? [英] Why does ace editor load with all text highlighted and how to remove it?

查看:215
本文介绍了为什么ace编辑器加载所有高亮显示的文本以及如何将其删除?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码如下:

$scope.aceIDEs='var hw = new function() {\n  console.log("Hello world!");\n}'

$scope.loadAceJSExample = function (_editor) {
_editor.setValue($scope.aceIDEs);
_editor.getSession().setUseWorker(false);
_editor.setHighlightActiveLine(true);
};

并且:

<div class="container fade-in" style='padding: 4em;'>
<div>
      ui-ace="{onLoad : loadAceJSExample,
      onChange : aceJSExampleChanged,
      useWrapMode : true,
      theme : 'github',
      showGutter: true,
      mode: 'javascript'

    }" />

我尝试调用_editor.getSession()。removeMarker();但是没有帮助

I tried calling _editor.getSession().removeMarker(); but did not help

每次我刷新它时都这样,一旦我单击它就会恢复正常:

Every time i refresh it looks like this,once i click in it returns to normal:

推荐答案

使用 _editor.session.setValue($ scope.aceIDEs); 也会重设undomanager。
或者,您也可以使用 _editor.setValue($ scope.aceIDEs,cursorPos); 。其中 cursorPos = -1 将光标放在开始处,而 cursorPos = 1 放在末尾。
或在设置值后调用 _editor.clearSelection()

Use _editor.session.setValue($scope.aceIDEs); which also resets undomanager. Alternatively you can use _editor.setValue($scope.aceIDEs, cursorPos);. where cursorPos=-1 puts cursor at start and cursorPos=1 at the end. Or call _editor.clearSelection() after setting value.

这篇关于为什么ace编辑器加载所有高亮显示的文本以及如何将其删除?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆