MCPcopy Create free account
hub / github.com/REditorSupport/vscode-R / getPreviousChunk

Function getPreviousChunk

src/rmarkdown/chunks.ts:176–189  ·  view source on GitHub ↗
(chunks: RMarkdownChunk[], line: number)

Source from the content-addressed store, hash-verified

174}
175
176function getPreviousChunk(chunks: RMarkdownChunk[], line: number): RMarkdownChunk | undefined {
177 const currentChunk = getCurrentChunk(chunks, line);
178 if (!currentChunk) {
179 return undefined;
180 }
181 if (currentChunk.id !== 1) {
182 // When cursor is below the last 'chunk end line', the definition of the previous chunk is the last chunk
183 const previousChunkId = currentChunk.endLine < line ? currentChunk.id : currentChunk.id - 1;
184 const previousChunk = chunks.find(i => i.id === previousChunkId);
185 return previousChunk;
186 } else {
187 return (currentChunk);
188 }
189}
190
191function getNextChunk(chunks: RMarkdownChunk[], line: number): RMarkdownChunk | undefined {
192 const currentChunk = getCurrentChunk(chunks, line);

Callers 3

runPreviousChunkFunction · 0.85
runAboveChunksFunction · 0.85
goToPreviousChunkFunction · 0.85

Calls 1

getCurrentChunkFunction · 0.85

Tested by

no test coverage detected