MCPcopy
hub / github.com/VSCodeVim/Vim / getCurrentParagraphBeginning

Function getCurrentParagraphBeginning

src/textobject/paragraph.ts:28–42  ·  view source on GitHub ↗
(pos: Position, trimWhite: boolean = false)

Source from the content-addressed store, hash-verified

26 * Get the beginning of the current paragraph.
27 */
28export 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
44function isLineBlank(line: number, trimWhite: boolean = false): boolean {
45 const text = TextEditor.getLine(line).text;

Callers 5

motion.test.tsFile · 0.90
execActionMethod · 0.90
execActionMethod · 0.90
execActionMethod · 0.90
getPreviousSentenceBeginFunction · 0.90

Calls 1

isLineBlankFunction · 0.85

Tested by

no test coverage detected