(pos: Position, trimWhite: boolean = false)
| 26 | * Get the beginning of the current paragraph. |
| 27 | */ |
| 28 | export function getCurrentParagraphBeginning(pos: Position, trimWhite: boolean = false): Position { |
| 29 | let line = pos.line; |
| 30 | |
| 31 | // If we're not in a paragraph yet, go up until we are. |
| 32 | while (line > 0 && isLineBlank(line, trimWhite)) { |
| 33 | line--; |
| 34 | } |
| 35 | |
| 36 | // Go until we're outside of the paragraph, or at the beginning of the document. |
| 37 | while (line > 0 && !isLineBlank(line, trimWhite)) { |
| 38 | line--; |
| 39 | } |
| 40 | |
| 41 | return new Position(line, 0); |
| 42 | } |
| 43 | |
| 44 | function isLineBlank(line: number, trimWhite: boolean = false): boolean { |
| 45 | const text = TextEditor.getLine(line).text; |
no test coverage detected