|
@@ -1361,34 +1361,34 @@ namespace Private {
|
|
|
*/
|
|
|
export function delSpaceToPrevTabStop(cm: CodeMirror.Editor): void {
|
|
|
let doc = cm.getDoc();
|
|
|
- var tabSize = cm.getOption('indentUnit');
|
|
|
- var ranges = doc.listSelections(); // handle multicursor
|
|
|
- for (var i = ranges.length - 1; i >= 0; i--) {
|
|
|
+ let tabSize = cm.getOption('indentUnit');
|
|
|
+ let ranges = doc.listSelections(); // handle multicursor
|
|
|
+ for (let i = ranges.length - 1; i >= 0; i--) {
|
|
|
// iterate reverse so any deletions don't overlap
|
|
|
- var head = ranges[i].head;
|
|
|
- var anchor = ranges[i].anchor;
|
|
|
- var isSelection = !posEq(head, anchor);
|
|
|
+ let head = ranges[i].head;
|
|
|
+ let anchor = ranges[i].anchor;
|
|
|
+ let isSelection = !posEq(head, anchor);
|
|
|
if (isSelection) {
|
|
|
doc.replaceRange('', anchor, head);
|
|
|
} else {
|
|
|
- var line = doc.getLine(head.line).substring(0, head.ch);
|
|
|
+ let line = doc.getLine(head.line).substring(0, head.ch);
|
|
|
if (line.match(/^\ +$/) !== null) {
|
|
|
// delete tabs
|
|
|
- var prevTabStop = (Math.ceil(head.ch / tabSize) - 1) * tabSize;
|
|
|
- var from = CodeMirror.Pos(head.line, prevTabStop);
|
|
|
+ let prevTabStop = (Math.ceil(head.ch / tabSize) - 1) * tabSize;
|
|
|
+ let from = CodeMirror.Pos(head.line, prevTabStop);
|
|
|
doc.replaceRange('', from, head);
|
|
|
} else {
|
|
|
// delete non-tabs
|
|
|
- if (head.ch == 0) {
|
|
|
- if (head.line != 0) {
|
|
|
- var from = CodeMirror.Pos(
|
|
|
+ if (head.ch === 0) {
|
|
|
+ if (head.line !== 0) {
|
|
|
+ let from = CodeMirror.Pos(
|
|
|
head.line - 1,
|
|
|
doc.getLine(head.line - 1).length
|
|
|
);
|
|
|
doc.replaceRange('', from, head);
|
|
|
}
|
|
|
} else {
|
|
|
- var from = CodeMirror.Pos(head.line, head.ch - 1);
|
|
|
+ let from = CodeMirror.Pos(head.line, head.ch - 1);
|
|
|
doc.replaceRange('', from, head);
|
|
|
}
|
|
|
}
|