(sourceFile *ast.SourceFile, position int, options lsutil.FormatCodeSettings)
| 175 | } |
| 176 | |
| 177 | func getBlockIndent(sourceFile *ast.SourceFile, position int, options lsutil.FormatCodeSettings) int { |
| 178 | // move backwards until we find a line with a non-whitespace character, |
| 179 | // then find the first non-whitespace character for that line. |
| 180 | current := position |
| 181 | for current > 0 { |
| 182 | ch, size := utf8.DecodeRuneInString(sourceFile.Text()[current:]) |
| 183 | if !stringutil.IsWhiteSpaceLike(ch) { |
| 184 | break |
| 185 | } |
| 186 | current -= size |
| 187 | } |
| 188 | |
| 189 | lineStart := GetLineStartPositionForPosition(current, sourceFile) |
| 190 | return FindFirstNonWhitespaceColumn(lineStart, current, sourceFile, options) |
| 191 | } |
| 192 | |
| 193 | func getActualIndentationForListItemBeforeComma(commaToken *ast.Node, sourceFile *ast.SourceFile, options lsutil.FormatCodeSettings) int { |
| 194 | // previous token is comma that separates items in list - find the previous item and try to derive indentation from it |
no test coverage detected