Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does ace editor load with all text highlighted and how to remove it?

My code looks like :

$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);
};

And:

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

    }" />

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: Before i click

like image 744
Iszlai Lehel Avatar asked Feb 26 '14 11:02

Iszlai Lehel


1 Answers

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.

like image 137
a user Avatar answered Sep 18 '22 16:09

a user