Fix markdown streaming duplication by splitting newlines first
- Added string-width library for proper terminal column width calculation - Fixed wrapLine() to split by newlines before wrapping (like Text component) - Fixed Loader interval leak by stopping before container removal - Changed loader message from 'Loading...' to 'Working...'
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
*/
|
||||
|
||||
import type { Terminal } from "./terminal.js";
|
||||
import { visibleWidth } from "./utils.js";
|
||||
|
||||
/**
|
||||
* Component interface - all components must implement this
|
||||
@@ -21,6 +22,8 @@ export interface Component {
|
||||
handleInput?(data: string): void;
|
||||
}
|
||||
|
||||
export { visibleWidth };
|
||||
|
||||
/**
|
||||
* Container - a component that contains other components
|
||||
*/
|
||||
@@ -211,6 +214,9 @@ export class TUI extends Container {
|
||||
// Render from first changed line to end
|
||||
for (let i = firstChanged; i < newLines.length; i++) {
|
||||
if (i > firstChanged) buffer += "\r\n";
|
||||
if (visibleWidth(newLines[i]) > width) {
|
||||
throw new Error("Rendered line exceeds terminal width");
|
||||
}
|
||||
buffer += newLines[i];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user