(n, how)
| 1515 | } |
| 1516 | |
| 1517 | function indentLine(n, how) { |
| 1518 | if (!how) how = "add"; |
| 1519 | if (how == "smart") { |
| 1520 | if (!mode.indent) how = "prev"; |
| 1521 | else var state = getStateBefore(n); |
| 1522 | } |
| 1523 | |
| 1524 | var line = getLine(n), curSpace = line.indentation(options.tabSize), |
| 1525 | curSpaceString = line.text.match(/^\s*/)[0], indentation; |
| 1526 | if (how == "prev") { |
| 1527 | if (n) indentation = getLine(n-1).indentation(options.tabSize); |
| 1528 | else indentation = 0; |
| 1529 | } |
| 1530 | else if (how == "smart") indentation = mode.indent(state, line.text.slice(curSpaceString.length), line.text); |
| 1531 | else if (how == "add") indentation = curSpace + options.indentUnit; |
| 1532 | else if (how == "subtract") indentation = curSpace - options.indentUnit; |
| 1533 | indentation = Math.max(0, indentation); |
| 1534 | var diff = indentation - curSpace; |
| 1535 | |
| 1536 | if (!diff) { |
| 1537 | if (sel.from.line != n && sel.to.line != n) return; |
| 1538 | var indentString = curSpaceString; |
| 1539 | } |
| 1540 | else { |
| 1541 | var indentString = "", pos = 0; |
| 1542 | if (options.indentWithTabs) |
| 1543 | for (var i = Math.floor(indentation / options.tabSize); i; --i) {pos += options.tabSize; indentString += "\t";} |
| 1544 | while (pos < indentation) {++pos; indentString += " ";} |
| 1545 | } |
| 1546 | |
| 1547 | replaceRange(indentString, {line: n, ch: 0}, {line: n, ch: curSpaceString.length}); |
| 1548 | } |
| 1549 | |
| 1550 | function loadMode() { |
| 1551 | mode = CodeMirror.getMode(options, options.mode); |
no test coverage detected