Jacob314/auto exit unconstrained height mode (#1293)
Co-authored-by: Scott Densmore <scottdensmore@mac.com>
This commit is contained in:
parent
6a1c62731b
commit
b831ffc1b3
|
@ -294,6 +294,26 @@ const App = ({ config, settings, startupWarnings = [] }: AppProps) => {
|
||||||
);
|
);
|
||||||
|
|
||||||
useInput((input: string, key: InkKeyType) => {
|
useInput((input: string, key: InkKeyType) => {
|
||||||
|
if (!constrainHeight) {
|
||||||
|
// Automatically re-enter constrain height mode if the user types
|
||||||
|
// anything. When constrainHeight==false, the user will experience
|
||||||
|
// significant flickering so it is best to disable it immediately when
|
||||||
|
// the user starts interacting with the app.
|
||||||
|
setConstrainHeight(true);
|
||||||
|
|
||||||
|
// If our pending history item happens to exceed the terminal height we will most likely need to refresh
|
||||||
|
// our static collection to ensure no duplication or tearing. This is currently working around a core bug
|
||||||
|
// in Ink which we have a PR out to fix: https://github.com/vadimdemedes/ink/pull/717
|
||||||
|
if (pendingHistoryItemRef.current && pendingHistoryItems.length > 0) {
|
||||||
|
const pendingItemDimensions = measureElement(
|
||||||
|
pendingHistoryItemRef.current,
|
||||||
|
);
|
||||||
|
if (pendingItemDimensions.height > availableTerminalHeight) {
|
||||||
|
refreshStatic();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (key.ctrl && input === 'o') {
|
if (key.ctrl && input === 'o') {
|
||||||
setShowErrorDetails((prev) => !prev);
|
setShowErrorDetails((prev) => !prev);
|
||||||
refreshStatic();
|
refreshStatic();
|
||||||
|
@ -315,7 +335,7 @@ const App = ({ config, settings, startupWarnings = [] }: AppProps) => {
|
||||||
}
|
}
|
||||||
handleExit(ctrlDPressedOnce, setCtrlDPressedOnce, ctrlDTimerRef);
|
handleExit(ctrlDPressedOnce, setCtrlDPressedOnce, ctrlDTimerRef);
|
||||||
} else if (key.ctrl && input === 's') {
|
} else if (key.ctrl && input === 's') {
|
||||||
setConstrainHeight((prev) => !prev);
|
setConstrainHeight(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -523,7 +543,7 @@ const App = ({ config, settings, startupWarnings = [] }: AppProps) => {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const mainAreaWidth = Math.floor(terminalWidth * 0.9);
|
const mainAreaWidth = Math.floor(terminalWidth * 0.9);
|
||||||
const debugConsoleMaxHeight = Math.max(terminalHeight * 0.2, 5);
|
const debugConsoleMaxHeight = Math.floor(Math.max(terminalHeight * 0.2, 5));
|
||||||
// Arbitrary threshold to ensure that items in the static area are large
|
// Arbitrary threshold to ensure that items in the static area are large
|
||||||
// enough but not too large to make the terminal hard to use.
|
// enough but not too large to make the terminal hard to use.
|
||||||
const staticAreaMaxItemHeight = Math.max(terminalHeight * 4, 100);
|
const staticAreaMaxItemHeight = Math.max(terminalHeight * 4, 100);
|
||||||
|
|
Loading…
Reference in New Issue