MCPcopy Create free account
hub / github.com/nodejs/node / insertIndentation

Function insertIndentation

test/fixtures/snapshot/typescript.js:147745–147759  ·  view source on GitHub ↗
(pos, indentation, lineAdded)

Source from the content-addressed store, hash-verified

147743 return lineAction;
147744 }
147745 function insertIndentation(pos, indentation, lineAdded) {
147746 var indentationString = getIndentationString(indentation, options);
147747 if (lineAdded) {
147748 // new line is added before the token by the formatting rules
147749 // insert indentation string at the very beginning of the token
147750 recordReplace(pos, 0, indentationString);
147751 }
147752 else {
147753 var tokenStart = sourceFile.getLineAndCharacterOfPosition(pos);
147754 var startLinePosition = ts.getStartPositionOfLine(tokenStart.line, sourceFile);
147755 if (indentation !== characterToColumn(startLinePosition, tokenStart.character) || indentationIsDifferent(indentationString, startLinePosition)) {
147756 recordReplace(startLinePosition, tokenStart.character, indentationString);
147757 }
147758 }
147759 }
147760 function characterToColumn(startLinePosition, characterInLine) {
147761 var column = 0;
147762 for (var i = 0; i < characterInLine; i++) {

Callers 2

indentMultilineCommentFunction · 0.85

Calls 4

getIndentationStringFunction · 0.85
recordReplaceFunction · 0.85
characterToColumnFunction · 0.85
indentationIsDifferentFunction · 0.85

Tested by

no test coverage detected