File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 {
You can’t perform that action at this time.
0 commit comments