Skip to content

Commit 9d7565c

Browse files
committed
Close tag on same line needs extra adjustment + 1
1 parent 9efbe9a commit 9d7565c

2 files changed

Lines changed: 20 additions & 16 deletions

File tree

lib/ice-coder.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ var ICEcoder = {
421421

422422
// On change
423423
cMonChange: function(thisCM,cMinstance,changeObj,cM) {
424-
var sels, rData, theTag, thisLine, thisChar, tagInfo, charDiff, repl1, repl2, thisToken, tTS, filepath, filename, fileExt;
424+
var sels, rData, theTag, thisLine, thisChar, tagInfo, charDiff, closeDiff, repl1, repl2, thisToken, tTS, filepath, filename, fileExt;
425425

426426
// Get the selections
427427
sels = thisCM.listSelections();
@@ -462,9 +462,13 @@ var ICEcoder = {
462462
charDiff = thisLine == changeObj.from.line
463463
? changeObj.text[0].length - changeObj.removed[0].length
464464
: 0;
465+
// Also need to adjust if we're in the close tag on same line
466+
closeDiff = tagInfo.at == "close" && thisLine == changeObj.from.line
467+
? changeObj.removed[0].length - changeObj.text[0].length + 1
468+
: 1
465469
// Work out the replace from and to positions
466-
repl1 = {line: thisLine, ch: thisChar+charDiff+(tagInfo.at == "open" ? 2 : 1)};
467-
repl2 = {line: thisLine, ch: thisChar+charDiff+(tagInfo.at == "open" ? 2 : 1)+rData[0].length};
470+
repl1 = {line: thisLine, ch: thisChar+charDiff+(tagInfo.at == "open" ? 2 : closeDiff)};
471+
repl2 = {line: thisLine, ch: thisChar+charDiff+(tagInfo.at == "open" ? 2 : closeDiff)+rData[0].length};
468472
}
469473
}
470474

0 commit comments

Comments
 (0)