From 9d7565c317f633ced17fab004697f360ecb134e7 Mon Sep 17 00:00:00 2001 From: Matt Pass Date: Thu, 25 Aug 2016 19:46:56 +0100 Subject: [PATCH] Close tag on same line needs extra adjustment + 1 --- lib/ice-coder.js | 10 +++++++--- lib/ice-coder.min.js | 26 +++++++++++++------------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/lib/ice-coder.js b/lib/ice-coder.js index 3a28a2f..1387d69 100644 --- a/lib/ice-coder.js +++ b/lib/ice-coder.js @@ -421,7 +421,7 @@ var ICEcoder = { // On change cMonChange: function(thisCM,cMinstance,changeObj,cM) { - var sels, rData, theTag, thisLine, thisChar, tagInfo, charDiff, repl1, repl2, thisToken, tTS, filepath, filename, fileExt; + var sels, rData, theTag, thisLine, thisChar, tagInfo, charDiff, closeDiff, repl1, repl2, thisToken, tTS, filepath, filename, fileExt; // Get the selections sels = thisCM.listSelections(); @@ -462,9 +462,13 @@ var ICEcoder = { charDiff = thisLine == changeObj.from.line ? changeObj.text[0].length - changeObj.removed[0].length : 0; + // Also need to adjust if we're in the close tag on same line + closeDiff = tagInfo.at == "close" && thisLine == changeObj.from.line + ? changeObj.removed[0].length - changeObj.text[0].length + 1 + : 1 // Work out the replace from and to positions - repl1 = {line: thisLine, ch: thisChar+charDiff+(tagInfo.at == "open" ? 2 : 1)}; - repl2 = {line: thisLine, ch: thisChar+charDiff+(tagInfo.at == "open" ? 2 : 1)+rData[0].length}; + repl1 = {line: thisLine, ch: thisChar+charDiff+(tagInfo.at == "open" ? 2 : closeDiff)}; + repl2 = {line: thisLine, ch: thisChar+charDiff+(tagInfo.at == "open" ? 2 : closeDiff)+rData[0].length}; } } diff --git a/lib/ice-coder.min.js b/lib/ice-coder.min.js index 6a74017..8d0dd36 100644 --- a/lib/ice-coder.min.js +++ b/lib/ice-coder.min.js @@ -17,15 +17,15 @@ Math.ceil((ICEcoder.filesW-ICEcoder.minFilesW)/2):ICEcoder.filesW=ICEcoder.minFi top.ICEcoder.updateByteDisplay()},cMonCursorActivity:function(a,b){var c;top.ICEcoder.getCaretPosition();top.ICEcoder.updateCharDisplay();top.ICEcoder.updateByteDisplay();a.removeLineClass(top.ICEcoder["cMActiveLine"+b],"background");a.getCursor("start").line==a.getCursor().line&&(top.ICEcoder["cMActiveLine"+b]=a.addLineClass(a.getCursor().line,"background","cm-s-activeLine"));"CSS"==top.ICEcoder.caretLocType&&top.ICEcoder.cssColorPreview();c=-1")&&"undefined"!=typeof e&&"undo"!=c.origin&&"redo"!=c.origin&&"undefined"!=typeof e.open&&"undefined"!=typeof e.close&&(f="open"==e.at?"close":"open",e=e[f].tag+";"+e[f].from.line+":"+e[f].from.ch,-1==top.ICEcoder.oppTagReplaceData.indexOf(e)&&top.ICEcoder.oppTagReplaceData.push(e))}, -cMonChange:function(a,b,c,d){var e,f,g,k,h,l,p,n,m;b=a.listSelections();top.ICEcoder.loadingFile||top.ICEcoder.redoTabHighlight(top.ICEcoder.selectedTab);setTimeout(function(){top.ICEcoder.scrollBarVisible=a.getScrollInfo().height>a.getScrollInfo().clientHeight;top.ICEcoder.setLayout()},0);if("undefined"!=typeof top.ICEcoder.oppTagReplaceData[0])for(var q=0;qa.defaultTextHeight()&&(f+=b.getLineHandle(e).height-a.defaultTextHeight());f>a.defaultTextHeight()&&top.ICEcoder.renderLineStyle.push(["main",c[d][2],"height",f+"px"]);for(e=0;ea.defaultTextHeight()&&(f+=a.getLineHandle(e).height-a.defaultTextHeight()); +cMonChange:function(a,b,c,d){var e,f,g,k,h,l,p,n,m,q;b=a.listSelections();top.ICEcoder.loadingFile||top.ICEcoder.redoTabHighlight(top.ICEcoder.selectedTab);setTimeout(function(){top.ICEcoder.scrollBarVisible=a.getScrollInfo().height>a.getScrollInfo().clientHeight;top.ICEcoder.setLayout()},0);if("undefined"!=typeof top.ICEcoder.oppTagReplaceData[0])for(var r=0;ra.defaultTextHeight()&&(f+=b.getLineHandle(e).height-a.defaultTextHeight());f>a.defaultTextHeight()&&top.ICEcoder.renderLineStyle.push(["main", +c[d][2],"height",f+"px"]);for(e=0;ea.defaultTextHeight()&&(f+=a.getLineHandle(e).height-a.defaultTextHeight()); f>a.defaultTextHeight()&&top.ICEcoder.renderLineStyle.push(["diff",c[d][4],"height",f+"px"]);for(e=0;ec&e>c&a[d-1]==b[e-1];d--)e--;return[c,d-c,e-c]},updatePreviewWindow:function(a,b,c,d){top.ICEcoder.previewWindow.location.pathname==b?-1<["htm","html","txt"].indexOf(d)?top.ICEcoder.previewWindow.document.documentElement.innerHTML=a.getValue():-1<["md"].indexOf(d)&&(top.ICEcoder.previewWindow.document.documentElement.innerHTML=mmd(a.getValue())):-1<["css"].indexOf(d)&&-1d.index+d[0].length;);(b=top.get("content").content (b.style.display="none"),top.get("header").appendChild(b),a.addWidget(a.getCursor(),top.get("cssColor"),!0))}},showColorPicker:function(a){top.get("blackMask").style.visibility="visible";top.get("mediaContainer").innerHTML='



'; farbtastic("picker","color");a&&top.get("picker").farbtastic.setColor(a)},initCanvasImage:function(a){var b,c;b=top.get("canvasPicker").getContext("2d");c=new Image;c.crossOrigin="Anonymous";c.src=a.src;c.onerror=function(){get("floatingContainer").style.visibility="hidden";get("canvasPickerColorInfo").style.display="none";get("canvasPickerCORSInfo").style.display="block"};c.onload=function(){top.get("canvasPicker").width=a.width;top.get("canvasPicker").height=a.height;b.drawImage(c,0,0,a.width,a.height); get("canvasPickerColorInfo").style.display="block";get("canvasPickerCORSInfo").style.display="none";top.get("canvasPicker").onmouseover=function(a){get("floatingContainer").style.visibility="visible"};top.get("canvasPicker").onmouseout=function(a){get("floatingContainer").style.visibility="hidden"}};top.document.getElementById("floatingContainer").style.backgroundSize=5*a.naturalWidth+"px "+5*a.naturalHeight+"px"},interactCanvasImage:function(a){var b,c,d,e,f,g,k,h,l,p,n,m,q;b=top.get("canvasPicker").getContext("2d"); -top.get("canvasPicker").onmousemove=function(u){c=u.pageX-this.offsetLeft;d=u.pageY-this.offsetTop;e=b.getImageData(c,d,1,1).data;f=e[0];g=e[1];k=e[2];h=f+","+g+","+k;l=top.ICEcoder.rgbToHex(f,g,k);top.get("rgbMouseXY").value=h;top.get("hexMouseXY").value="#"+l;top.get("hexMouseXY").style.backgroundColor=top.get("rgbMouseXY").style.backgroundColor="#"+l;p=128>f||128>g||128>k&&200>f&&200>g&&50f||128>g||128>k&&200>f&&200>g&&50';top.ICEcoder.showHide("show",top.get("blackMask"))},githubTokenAsk:function(a){if(githubAuthToken= top.ICEcoder.getInput(top.t["Please enter your..."],""))top.ICEcoder.filesFrame.contentWindow.frames.fileControl.location.href="lib/github.php?action=auth&token="+githubAuthToken+"&goNext="+a+"&csrf="+top.ICEcoder.csrf,githubAuthToken=""},showHideGithubNav:function(a){top.get("githubNav").style.display="show"==a?"block":"none";top.get("fileNav").style.display="show"==a?"none":"block"},githubManager:function(){top.ICEcoder.githubAuthTokenSet?(top.get("mediaContainer").innerHTML='', top.ICEcoder.showHide("show",top.get("blackMask"))):top.ICEcoder.githubTokenAsk("showManager")},githubDiffToggle:function(){var a;if(!top.ICEcoder.githubAuthTokenSet)top.ICEcoder.githubTokenAsk("loadFiles");else if(top.ICEcoder.githubDiff||top.ICEcoder.ask(top.t["This will compare..."]))top.ICEcoder.githubDiff=!top.ICEcoder.githubDiff,a=top.ICEcoder.githubDiff?"true":"false",top.ICEcoder.filesFrame.src="files.php?githubDiff="+a+"&csrf="+top.ICEcoder.csrf},ftpManager:function(){top.get("mediaContainer").innerHTML= -'';top.ICEcoder.showHide("show",top.get("blackMask"))},useNewSettings:function(a,b,c,d,e,f,g,k,h,l,p,n,m,q,u,w,v,x,y,z,A,B,C,D){var r,t=a.slice(0,a.lastIndexOf("?")),t=t.slice(t.lastIndexOf("/")+1,t.lastIndexOf("."));top.ICEcoder.theme!==t&&(top.ICEcoder.theme=t,"editor"==top.ICEcoder.theme&&(top.ICEcoder.theme="icecoder"),r=document.createElement("link"),r.setAttribute("rel","stylesheet"),r.setAttribute("type", -"text/css"),r.setAttribute("href",a),top.ICEcoder.content.contentWindow.document.getElementsByTagName("head")[0].appendChild(r),r=-1<"3024-day base16-light eclipse elegant mdn-like neat neo paraiso-light solarized the-matrix xq-light".split(" ").indexOf(top.ICEcoder.theme)?"#ccc":-1<"3024-night blackboard colorforth liquibyte night tomorrow-night-bright tomorrow-night-eighties vibrant-ink".split(" ").indexOf(top.ICEcoder.theme)?"#888":"#000",top.ICEcoder.switchTab(top.ICEcoder.selectedTab));b!=top.ICEcoder.codeAssist&& +'';top.ICEcoder.showHide("show",top.get("blackMask"))},useNewSettings:function(a,b,c,d,e,f,g,k,h,l,p,n,m,q,r,w,v,x,y,z,A,B,C,D){var t,u=a.slice(0,a.lastIndexOf("?")),u=u.slice(u.lastIndexOf("/")+1,u.lastIndexOf("."));top.ICEcoder.theme!==u&&(top.ICEcoder.theme=u,"editor"==top.ICEcoder.theme&&(top.ICEcoder.theme="icecoder"),t=document.createElement("link"),t.setAttribute("rel","stylesheet"),t.setAttribute("type", +"text/css"),t.setAttribute("href",a),top.ICEcoder.content.contentWindow.document.getElementsByTagName("head")[0].appendChild(t),t=-1<"3024-day base16-light eclipse elegant mdn-like neat neo paraiso-light solarized the-matrix xq-light".split(" ").indexOf(top.ICEcoder.theme)?"#ccc":-1<"3024-night blackboard colorforth liquibyte night tomorrow-night-bright tomorrow-night-eighties vibrant-ink".split(" ").indexOf(top.ICEcoder.theme)?"#888":"#000",top.ICEcoder.switchTab(top.ICEcoder.selectedTab));b!=top.ICEcoder.codeAssist&& (top.get("codeAssist").checked=b,top.ICEcoder.codeAssistToggle());c!=top.ICEcoder.lockedNav&&(top.ICEcoder.lockUnlockNav(),ICEcoder.changeFilesW(c?"expand":"contract"),top.ICEcoder.hideFileMenu());a=top.document.styleSheets[0];b=a.rules?"rules":"cssRules";a[b][0].style.fontSize=g;a=ICEcoder.filesFrame.contentWindow.document.styleSheets[3];b=a.rules?"rules":"cssRules";a[b][0].style.fontSize=g;a=ICEcoder.content.contentWindow.document.styleSheets[4];b=a.rules?"rules":"cssRules";a[b][0].style.fontSize= -g;a[b][4].style["border-left-width"]=f?"1px":"0";a[b][4].style["margin-left"]=f?"-1px":"0";a[b][2].style.cssText="background-color: "+r+" !important";top.ICEcoder.lineWrapping=k;top.ICEcoder.lineNumbers=h;top.ICEcoder.showTrailingSpace=l;top.ICEcoder.matchBrackets=p;top.ICEcoder.autoCloseTags=n;top.ICEcoder.autoCloseBrackets=m;top.ICEcoder.indentWithTabs=q;top.ICEcoder.indentSize=w;top.ICEcoder.indentAuto=u;for(f=0;f