comparison s4-main.js @ 948:1310b29b6ab1 draft

Prevent \end completion when not enclosed with \begin
author HIROSE Yuuji <yuuji@gentei.org>
date Fri, 29 Oct 2021 17:21:43 +0900
parents b7f9c4ce8cbd
children d8a258cc8a7d
comparison
equal deleted inserted replaced
947:b7f9c4ce8cbd 948:1310b29b6ab1
667 if (text.substr(pos).startsWith("}")) { 667 if (text.substr(pos).startsWith("}")) {
668 area.setRangeText("", pos, pos+1); 668 area.setRangeText("", pos, pos+1);
669 // e.preventDefault(); 669 // e.preventDefault();
670 } 670 }
671 let inbegend = isInBeginEnd(area, pos); 671 let inbegend = isInBeginEnd(area, pos);
672 if (!inbegend) return;
672 let nextendpos = text.substr(pos).indexOf("\\end{"); 673 let nextendpos = text.substr(pos).indexOf("\\end{");
673 let nextcurend = text.substr(pos).indexOf("\\end{"+inbegend+"}"); 674 let nextcurend = text.substr(pos).indexOf("\\end{"+inbegend+"}");
674 console.log("ib="+inbegend+", nepos="+nextendpos+", ncur="+nextcurend);
675 if (nextcurend<0 || nextendpos!=nextcurend) { 675 if (nextcurend<0 || nextendpos!=nextcurend) {
676 area.setRangeText("}\n\n\\end{"+inbegend+"}", pos, pos); 676 area.setRangeText("}\n\n\\end{"+inbegend+"}", pos, pos);
677 area.selectionStart = pos+2; 677 area.selectionStart = pos+2;
678 e.preventDefault(); 678 e.preventDefault();
679 } 679 }

yatex.org