fix: when filtering, the suggestions shouldn't shift from top view to bottom view (#186)

Signed-off-by: Chapman Pendery <cpendery@vt.edu>
This commit is contained in:
Chapman Pendery
2024-03-05 21:54:47 -08:00
committed by GitHub
parent ec841bba31
commit bddf56f2f0
+4 -4
View File
@@ -36,7 +36,7 @@ export const render = async (shell: Shell, underTest: boolean) => {
// Considers when data includes newlines which have shifted the cursor position downwards
const newlines = Math.max((data.match(/\r/g) || []).length, (data.match(/\n/g) || []).length);
const linesOfInterest = MAX_LINES + newlines;
if (term.getCursorState().remainingLines <= previousSuggestionsRows) {
if (term.getCursorState().remainingLines <= MAX_LINES) {
// handles when suggestions get loaded before shell output so you need to always clear below output as a precaution
if (term.getCursorState().remainingLines != 0) {
writeOutput(ansi.cursorHide + ansi.cursorSavePosition + eraseLinesBelow(linesOfInterest + 1) + ansi.cursorRestorePosition);
@@ -64,7 +64,7 @@ export const render = async (shell: Shell, underTest: boolean) => {
if (suggestion.data != "" && commandState.cursorTerminated && !commandState.hasOutput) {
if (hasActiveSuggestions) {
if (term.getCursorState().remainingLines < suggestion.rows) {
if (term.getCursorState().remainingLines < MAX_LINES) {
writeOutput(
ansi.cursorHide +
ansi.cursorSavePosition +
@@ -90,7 +90,7 @@ export const render = async (shell: Shell, underTest: boolean) => {
);
}
} else {
if (term.getCursorState().remainingLines < suggestion.rows) {
if (term.getCursorState().remainingLines < MAX_LINES) {
writeOutput(ansi.cursorHide + ansi.cursorSavePosition + ansi.cursorUp() + suggestion.data + ansi.cursorRestorePosition + ansi.cursorShow);
} else {
writeOutput(
@@ -106,7 +106,7 @@ export const render = async (shell: Shell, underTest: boolean) => {
hasActiveSuggestions = true;
} else {
if (hasActiveSuggestions) {
if (term.getCursorState().remainingLines <= previousSuggestionsRows) {
if (term.getCursorState().remainingLines <= MAX_LINES) {
writeOutput(
ansi.cursorHide +
ansi.cursorSavePosition +