(pos int, indentation int, lineAdded bool)
| 866 | } |
| 867 | |
| 868 | func (w *formatSpanWorker) insertIndentation(pos int, indentation int, lineAdded bool) { |
| 869 | indentationString := getIndentationString(indentation, w.formattingContext.Options) |
| 870 | if lineAdded { |
| 871 | // new line is added before the token by the formatting rules |
| 872 | // insert indentation string at the very beginning of the token |
| 873 | w.recordReplace(pos, 0, indentationString) |
| 874 | } else { |
| 875 | tokenStartLine, tokenStartCharacter := scanner.GetECMALineAndByteOffsetOfPosition(w.sourceFile, pos) |
| 876 | startLinePosition := int(scanner.GetECMALineStarts(w.sourceFile)[tokenStartLine]) |
| 877 | if indentation != w.characterToColumn(startLinePosition, tokenStartCharacter) || w.indentationIsDifferent(indentationString, startLinePosition) { |
| 878 | w.recordReplace(startLinePosition, tokenStartCharacter, indentationString) |
| 879 | } |
| 880 | } |
| 881 | } |
| 882 | |
| 883 | func (w *formatSpanWorker) characterToColumn(startLinePosition int, characterInLine int) int { |
| 884 | column := 0 |
no test coverage detected