Skip to content

Commit 98b6444

Browse files
committed
fix returnstartline... to be the same as startline... (computed correctly that is)
1 parent 4a5dee6 commit 98b6444

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

frontend/app/view/term/term-wsh.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,19 @@ export class TermWshClient extends WshClient {
148148

149149
const lines = bufferLinesToText(buffer, startBufferIndex, endBufferIndex);
150150

151+
// Convert buffer indices to "from bottom" line numbers.
152+
// "from bottom" 0 = most recent line; higher numbers = older lines.
153+
// The buffer range [startBufferIndex, endBufferIndex) maps to
154+
// "from bottom" range [totalLines - endBufferIndex, totalLines - startBufferIndex).
155+
// The first returned line is at "from bottom" position: totalLines - endBufferIndex.
151156
let returnLines = lines;
152-
let returnStartLine = startBufferIndex;
157+
let returnStartLine = totalLines - endBufferIndex;
153158
if (lines.length > 1000) {
159+
// there is a small bug here since this is computing a physical start line
160+
// after the lines have already been combined (because of potential wrapping)
161+
// for now this isn't worth fixing, just noted
154162
returnLines = lines.slice(lines.length - 1000);
155-
returnStartLine = startBufferIndex + (lines.length - 1000);
163+
returnStartLine = (totalLines - endBufferIndex) + (lines.length - 1000);
156164
}
157165

158166
return {

0 commit comments

Comments
 (0)