From 405aafaa407dc6af99d42de98d508729dbfa74d9 Mon Sep 17 00:00:00 2001 From: Adam Babik Date: Thu, 5 Jan 2023 17:27:51 +0100 Subject: [PATCH] F --- internal/kernel/prompt.go | 2 +- internal/kernel/service.go | 1 + internal/kernel/session.go | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/kernel/prompt.go b/internal/kernel/prompt.go index b63991026..465e159ab 100644 --- a/internal/kernel/prompt.go +++ b/internal/kernel/prompt.go @@ -45,5 +45,5 @@ func detectPrompt(cmdName string) ([]byte, error) { break } } - return prompt, nil + return dropANSIEscape(prompt), nil } diff --git a/internal/kernel/service.go b/internal/kernel/service.go index 5e3c0b266..52b4e8d9a 100644 --- a/internal/kernel/service.go +++ b/internal/kernel/service.go @@ -30,6 +30,7 @@ func (m *kernelServiceServer) PostSession(ctx context.Context, req *kernelv1.Pos if len(prompt) == 0 { var err error prompt, err = DetectPrompt(req.CommandName) + m.logger.Info("detected prompt", zap.Error(err), zap.ByteString("prompt", prompt)) if err != nil { return nil, fmt.Errorf("failed to detect prompt: %w", err) } diff --git a/internal/kernel/session.go b/internal/kernel/session.go index 94c3183b9..b15e3d79f 100644 --- a/internal/kernel/session.go +++ b/internal/kernel/session.go @@ -252,7 +252,7 @@ func scanLinesPrompt(data []byte, atEOF bool, prompt []byte) (advance int, token newLineIdx := bytes.IndexByte(data, '\n') if promptIdx >= 0 && (newLineIdx < 0 || promptIdx < newLineIdx) { m := promptIdx + len(prompt) - if len(data) >= m && data[m] == ' ' { + if len(data) > m && data[m] == ' ' { m++ } return m, data[0 : promptIdx+len(prompt)], nil