Commit 278cea8f authored by Antoine Thevenet's avatar Antoine Thevenet
Browse files

Changed the process to format the nchoice inserted in the editor ace

parent b4d55e0b
Pipeline #14384 failed with stages
in 29 seconds
......@@ -325,10 +325,10 @@ function insertStatement(statementType, pluginName, testName, pluginId) {
}
xmlToInsert += endXml;
xmlToInsert = formatXml(xmlToInsert);
//delete the \n added by format xml
xmlToInsert = xmlToInsert.substring(0, xmlToInsert.length - 1);
//format the insertion
var cursorPositionToInsert = [cursorPosition["row"], cursorPosition["column"]]
xmlToInsert = formatInsertion(xmlToInsert, cursorPositionToInsert);
......@@ -365,17 +365,21 @@ retrieveTest = function retrieveTest(pluginName, testName, cache) {
function insertChoice() {
var editor = ace.edit(getActiveEditor());
var completeText = editor.getValue();
var xml = "<nchoice>\n\t<choice proba=\"1\">\n\t</choice><choice proba=\"1\">\n\t</choice>\n</nchoice>";
xml = formatXml(xml);
var answerPositionToInsertPrimitive = positionToInsert();
var cursorPositionToInsert = answerPositionToInsertPrimitive[0];
// xml = addTabXml(xml, cursorPositionToInsert, completeText);
xml = formatInsertion(xml, cursorPositionToInsert);
var cursorPosition = editor.getCursorPosition();
var xmlToInsert = "<nchoice>\n\t<choice proba=\"1\">\n\t</choice><choice proba=\"1\">\n\t</choice>\n</nchoice>";
xmlToInsert = formatXml(xmlToInsert);
//delete the \n added by format xml
xmlToInsert = xmlToInsert.substring(0, xmlToInsert.length - 1);
//format the insertion
var cursorPositionToInsert = [cursorPosition["row"], cursorPosition["column"]]
xmlToInsert = formatInsertion(xmlToInsert, cursorPositionToInsert);
//insert the formatted xml
var Range = ace.require('ace/range').Range;
editor.session.replace(new Range(cursorPositionToInsert[1], cursorPositionToInsert[0], cursorPositionToInsert[1], cursorPositionToInsert[0]), xml);
editor.session.replace(new Range(cursorPosition["row"], cursorPosition["column"], cursorPosition["row"], cursorPosition["column"]), xmlToInsert);
}
/*------------------------------------------------------------------
-----------------------------Behavior-------------------------------
-------------------------------------------------------------------*/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment