2013-11-21 40 views
2

我正在將腳本加載到Ace編輯器中,並且在渲染時,整個腳本突出顯示,就好像有人做了ctrl + a(全選)。如何使內容「取消選中」......似乎它應該默認以這種方式工作。ACE編輯器 - >加載的腳本默認高亮顯示

基於文檔,好像我可以解決方法:

session.getSelection().clearSelection(); 

...基於this SO question,看來我也可以這樣做:

editor.setValue(str, -1) // moves cursor to the start 
editor.setValue(str, 1) // moves cursor to the end 

無論工作..

+0

你能不能做一個jsbin演示重現問題,它似乎做工精細http://jsbin.com/ojijeb/180/edit –

+0

是的,我會的,謝謝你的職位。我的背景是ace和ace-ui角度模塊,還有一個指令包裝。所以看到它的作用,我可能會找到解決方案將其分解到裸露的元素。敬請關注。 –

回答

0

您可能可以刪除以下某些內容,但很難說沒有看到您的代碼,但是這應該可以覆蓋它。

editor.setValue('hello world'); 
editor.clearSelection(1); 
editor.gotoLine(1); 
editor.getSession().setScrollTop(1); 
editor.blur(); 
editor.focus();