Skip to content

Commit 4a8a18b

Browse files
committed
fix bug in termscrollback (lastcommand) and fix bug with wrong route
1 parent 3613050 commit 4a8a18b

2 files changed

Lines changed: 16 additions & 5 deletions

File tree

cmd/wsh/cmd/wshcmd-termscrollback.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"github.com/wavetermdev/waveterm/pkg/waveobj"
1313
"github.com/wavetermdev/waveterm/pkg/wshrpc"
1414
"github.com/wavetermdev/waveterm/pkg/wshrpc/wshclient"
15+
"github.com/wavetermdev/waveterm/pkg/wshutil"
1516
)
1617

1718
var termScrollbackCmd = &cobra.Command{
@@ -75,7 +76,7 @@ func termScrollbackRun(cmd *cobra.Command, args []string) (rtnErr error) {
7576
}
7677

7778
result, err := wshclient.TermGetScrollbackLinesCommand(RpcClient, scrollbackData, &wshrpc.RpcOpts{
78-
Route: fullORef.String(),
79+
Route: wshutil.MakeFeBlockRouteId(fullORef.OID),
7980
Timeout: 5000,
8081
})
8182
if err != nil {

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

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,23 @@ export class TermWshClient extends WshClient {
128128
}
129129

130130
let startBufferIndex = 0;
131+
let endBufferIndex = totalLines;
131132
if (termWrap.promptMarkers.length > 0) {
132-
const lastMarker = termWrap.promptMarkers[termWrap.promptMarkers.length - 1];
133-
const markerLine = lastMarker.line;
134-
startBufferIndex = totalLines - markerLine;
133+
// The last marker is the current prompt, so we want the second-to-last for the previous command
134+
// If there's only one marker, use it (edge case for first command)
135+
const markerIndex = termWrap.promptMarkers.length > 1
136+
? termWrap.promptMarkers.length - 2
137+
: termWrap.promptMarkers.length - 1;
138+
const commandStartMarker = termWrap.promptMarkers[markerIndex];
139+
startBufferIndex = commandStartMarker.line;
140+
141+
// End at the last marker (current prompt) if there are multiple markers
142+
if (termWrap.promptMarkers.length > 1) {
143+
const currentPromptMarker = termWrap.promptMarkers[termWrap.promptMarkers.length - 1];
144+
endBufferIndex = currentPromptMarker.line;
145+
}
135146
}
136147

137-
const endBufferIndex = totalLines;
138148
const lines = bufferLinesToText(buffer, startBufferIndex, endBufferIndex);
139149

140150
let returnLines = lines;

0 commit comments

Comments
 (0)