Skip to content

A self-improving RLM agent for coding workflows and long-running autonomous tasks.

Rust

Highlight the whole ipython cell so multi-line strings keep color (#1692)

Sebastian Müllera44b07ee9621
diff --git a/packages/coding-agent/.changes/multiline-python-string-highlight.md b/packages/coding-agent/.changes/multiline-python-string-highlight.md
new file mode 100644
index 0000000000..e3bb22623e
--- /dev/null
+++ b/packages/coding-agent/.changes/multiline-python-string-highlight.md
@@ -0,0 +1 @@
+- Fixed syntax highlighting in the expanded python tool-call view: triple-quoted strings spanning multiple lines now keep their string color instead of only the first line.
diff --git a/packages/coding-agent/src/modes/interactive/components/ipython-cell.ts b/packages/coding-agent/src/modes/interactive/components/ipython-cell.ts
index 68a8e50396..14699deb77 100644
--- a/packages/coding-agent/src/modes/interactive/components/ipython-cell.ts
+++ b/packages/coding-agent/src/modes/interactive/components/ipython-cell.ts
@@ -507,9 +507,14 @@ export class IPythonCellComponent implements Component {
this.addBlank(lines, width);
const isBashCell = parseIpythonBashCell(code) !== undefined;
const rawLines = code.split("\n");
+ // Highlight the whole cell at once so multi-line strings keep their color.
+ const highlightedLines = isBashCell ? [] : highlightCode(code, "python");
for (const [index, rawLine] of rawLines.entries()) {
const prefix = index === 0 ? theme.fg("dim", "› ") : theme.fg("dim", " ");
- const highlighted = this.highlightInputLine(rawLine, isBashCell);
+ const highlighted =
+ isBashCell || MAGIC_LINE_PATTERN.test(rawLine) || parseIpythonBashCell(rawLine) !== undefined
+ ? theme.fg("bashMode", rawLine)
+ : (highlightedLines[index] ?? theme.fg("mdCodeBlock", rawLine));
this.addWrapped(lines, prefix, highlighted || " ", width);
}