(chunks: RMarkdownChunk[], line: number)
| 174 | } |
| 175 | |
| 176 | function 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 | |
| 191 | function getNextChunk(chunks: RMarkdownChunk[], line: number): RMarkdownChunk | undefined { |
| 192 | const currentChunk = getCurrentChunk(chunks, line); |
no test coverage detected