0
我想做一些像背景工作的東西。它應該自動更新一些代碼(在與光標不同的地方),而無需將光標移動到最後更改的單詞。這可能與editor.session.replace或.insert?是否可以在不改變光標位置的情況下更新Ace Editor內部的值?
我想做一些像背景工作的東西。它應該自動更新一些代碼(在與光標不同的地方),而無需將光標移動到最後更改的單詞。這可能與editor.session.replace或.insert?是否可以在不改變光標位置的情況下更新Ace Editor內部的值?
這樣做的一種方法是,存儲當前光標位置,插入數據並將光標位置設置爲初始點。
//Get the Current Positon
var currentPosition = editor.selection.getCursor();
//Insert data into the editor
editor.setValue(data);
editor.clearSelection();
//Set the cursor to the Initial Point
editor.gotoLine(currentPosition.row, currentPosition.column);