fix: InputPrompt wrapped lines maintain highlighting, increase responsiveness in narrow cases (#7656)

Co-authored-by: Jacob Richman <jacob314@gmail.com>
Co-authored-by: Arya Gummadi <aryagummadi@google.com>
This commit is contained in:
Pyush Sinha
2025-09-17 13:17:50 -07:00
committed by GitHub
parent 0b10ba2ca9
commit d2b8ff5deb
7 changed files with 150 additions and 34 deletions

View File

@@ -113,6 +113,7 @@ describe('InputPrompt', () => {
mockBuffer.cursor = [0, newText.length];
mockBuffer.viewportVisualLines = [newText];
mockBuffer.allVisualLines = [newText];
mockBuffer.visualToLogicalMap = [[0, 0]];
}),
replaceRangeByOffset: vi.fn(),
viewportVisualLines: [''],
@@ -138,6 +139,7 @@ describe('InputPrompt', () => {
replaceRange: vi.fn(),
deleteWordLeft: vi.fn(),
deleteWordRight: vi.fn(),
visualToLogicalMap: [[0, 0]],
} as unknown as TextBuffer;
mockShellHistory = {
@@ -1344,6 +1346,12 @@ describe('InputPrompt', () => {
mockBuffer.viewportVisualLines = text.split('\n');
mockBuffer.allVisualLines = text.split('\n');
mockBuffer.visualCursor = [2, 5]; // cursor at the end of "world"
// Provide a visual-to-logical mapping for each visual line
mockBuffer.visualToLogicalMap = [
[0, 0], // 'hello' starts at col 0 of logical line 0
[1, 0], // '' (blank) is logical line 1, col 0
[2, 0], // 'world' is logical line 2, col 0
];
const { stdout, unmount } = renderWithProviders(
<InputPrompt {...props} />,