Add further scrollback option for longer terminal history
This commit is contained in:
@@ -7,11 +7,13 @@ final class AppSettingsControllerTests: XCTestCase {
|
||||
let store = InMemoryAppSettingsStore()
|
||||
var settings = AppSettings.default
|
||||
settings.terminal.shellPath = "/opt/homebrew/bin/fish"
|
||||
settings.terminal.scrollbackLines = 12_000
|
||||
store.storedSettings = settings
|
||||
|
||||
let controller = AppSettingsController(store: store)
|
||||
|
||||
XCTAssertEqual(controller.terminalSessionConfiguration.shellPath, "/opt/homebrew/bin/fish")
|
||||
XCTAssertEqual(controller.terminalSessionConfiguration.scrollbackLines, 12_000)
|
||||
}
|
||||
|
||||
func testTerminalSizePresetsDecodeFromTypedSettings() {
|
||||
|
||||
@@ -26,6 +26,7 @@ final class AppSettingsStoreTests: XCTestCase {
|
||||
settings.appearance.blurRadius = 4.5
|
||||
settings.terminal.fontSize = 16
|
||||
settings.terminal.themeRawValue = TerminalTheme.dracula.rawValue
|
||||
settings.terminal.scrollbackLines = 25_000
|
||||
settings.terminal.sizePresetsJSON = TerminalSizePresetStore.encodePresets([
|
||||
TerminalSizePreset(name: "Wide", width: 960, height: 420, hotkey: .cmdShiftDigit(4))
|
||||
])
|
||||
|
||||
@@ -306,7 +306,7 @@ private final class TestAppSettingsStore: AppSettingsStoreType {
|
||||
}
|
||||
|
||||
private final class ScreenRegistryTestSettingsProvider: TerminalSessionConfigurationProviding {
|
||||
let terminalSessionConfiguration = TerminalSessionConfiguration(fontSize: 13, theme: .terminalApp, shellPath: "")
|
||||
let terminalSessionConfiguration = TerminalSessionConfiguration(fontSize: 13, theme: .terminalApp, shellPath: "", scrollbackLines: 500)
|
||||
let hotkeySettings = AppSettings.default.hotkeys
|
||||
let terminalSizePresets = TerminalSizePresetStore.loadDefaults()
|
||||
}
|
||||
@@ -317,6 +317,7 @@ private struct ScreenRegistryUnusedTerminalSessionFactory: TerminalSessionFactor
|
||||
fontSize: CGFloat,
|
||||
theme: TerminalTheme,
|
||||
shellPath: String,
|
||||
scrollbackLines: Int,
|
||||
initialDirectory: String?
|
||||
) -> TerminalSession {
|
||||
fatalError("ScreenRegistryTests should not create live terminal sessions.")
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
import XCTest
|
||||
@testable import CommandNotch
|
||||
|
||||
final class TerminalScrollCoordinatorTests: XCTestCase {
|
||||
func testScrollAwayFromBottomDisablesOutputFollow() {
|
||||
let coordinator = TerminalScrollCoordinator()
|
||||
|
||||
coordinator.terminalDidScroll(to: 0.42, canScroll: true)
|
||||
|
||||
XCTAssertFalse(coordinator.followsOutput)
|
||||
XCTAssertEqual(coordinator.outputRestorePosition(canScroll: true) ?? .nan, 0.42, accuracy: 0.0001)
|
||||
}
|
||||
|
||||
func testTypingReEnablesFollowAndRequestsJumpToBottom() {
|
||||
let coordinator = TerminalScrollCoordinator()
|
||||
coordinator.terminalDidScroll(to: 0.42, canScroll: true)
|
||||
|
||||
let shouldJump = coordinator.userDidStartTyping()
|
||||
|
||||
XCTAssertTrue(shouldJump)
|
||||
XCTAssertTrue(coordinator.followsOutput)
|
||||
XCTAssertNil(coordinator.outputRestorePosition(canScroll: true))
|
||||
}
|
||||
|
||||
func testScrollingBackToBottomReEnablesOutputFollow() {
|
||||
let coordinator = TerminalScrollCoordinator()
|
||||
coordinator.terminalDidScroll(to: 0.42, canScroll: true)
|
||||
|
||||
coordinator.terminalDidScroll(to: 1, canScroll: true)
|
||||
|
||||
XCTAssertTrue(coordinator.followsOutput)
|
||||
XCTAssertNil(coordinator.outputRestorePosition(canScroll: true))
|
||||
}
|
||||
|
||||
func testSuppressedTrackingIgnoresProgrammaticScrollUpdates() {
|
||||
let coordinator = TerminalScrollCoordinator()
|
||||
coordinator.terminalDidScroll(to: 0.42, canScroll: true)
|
||||
|
||||
coordinator.suppressTracking {
|
||||
coordinator.terminalDidScroll(to: 1, canScroll: true)
|
||||
}
|
||||
|
||||
XCTAssertFalse(coordinator.followsOutput)
|
||||
XCTAssertEqual(coordinator.outputRestorePosition(canScroll: true) ?? .nan, 0.42, accuracy: 0.0001)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
import XCTest
|
||||
@testable import CommandNotch
|
||||
|
||||
final class TerminalScrollbackEstimatorTests: XCTestCase {
|
||||
func testEstimateIncreasesAsScrollbackGrows() {
|
||||
let small = TerminalScrollbackEstimator.estimate(
|
||||
scrollbackLines: 5_000,
|
||||
fontSize: 13,
|
||||
openWidth: 640,
|
||||
openHeight: 350
|
||||
)
|
||||
let large = TerminalScrollbackEstimator.estimate(
|
||||
scrollbackLines: 100_000,
|
||||
fontSize: 13,
|
||||
openWidth: 640,
|
||||
openHeight: 350
|
||||
)
|
||||
|
||||
XCTAssertGreaterThan(large.bytes, small.bytes)
|
||||
XCTAssertGreaterThan(large.columns, 0)
|
||||
XCTAssertGreaterThan(large.rows, 0)
|
||||
}
|
||||
|
||||
func testEstimateClampsNegativeScrollbackToZero() {
|
||||
let estimate = TerminalScrollbackEstimator.estimate(
|
||||
scrollbackLines: -1_000,
|
||||
fontSize: 13,
|
||||
openWidth: 640,
|
||||
openHeight: 350
|
||||
)
|
||||
|
||||
XCTAssertGreaterThan(estimate.bytes, 0)
|
||||
}
|
||||
}
|
||||
@@ -191,7 +191,7 @@ private final class InMemoryWorkspaceStore: WorkspaceStoreType {
|
||||
}
|
||||
|
||||
private final class TestSettingsProvider: TerminalSessionConfigurationProviding {
|
||||
let terminalSessionConfiguration = TerminalSessionConfiguration(fontSize: 13, theme: .terminalApp, shellPath: "")
|
||||
let terminalSessionConfiguration = TerminalSessionConfiguration(fontSize: 13, theme: .terminalApp, shellPath: "", scrollbackLines: 500)
|
||||
let hotkeySettings = AppSettings.default.hotkeys
|
||||
let terminalSizePresets = TerminalSizePresetStore.loadDefaults()
|
||||
}
|
||||
@@ -204,6 +204,7 @@ private final class RecordingTerminalSessionFactory: TerminalSessionFactoryType
|
||||
fontSize: CGFloat,
|
||||
theme: TerminalTheme,
|
||||
shellPath: String,
|
||||
scrollbackLines: Int,
|
||||
initialDirectory: String?
|
||||
) -> TerminalSession {
|
||||
requestedDirectories.append(initialDirectory)
|
||||
@@ -211,6 +212,7 @@ private final class RecordingTerminalSessionFactory: TerminalSessionFactoryType
|
||||
fontSize: fontSize,
|
||||
theme: theme,
|
||||
shellPath: shellPath,
|
||||
scrollbackLines: scrollbackLines,
|
||||
initialDirectory: initialDirectory,
|
||||
startImmediately: false
|
||||
)
|
||||
@@ -223,6 +225,7 @@ private struct UnusedTerminalSessionFactory: TerminalSessionFactoryType {
|
||||
fontSize: CGFloat,
|
||||
theme: TerminalTheme,
|
||||
shellPath: String,
|
||||
scrollbackLines: Int,
|
||||
initialDirectory: String?
|
||||
) -> TerminalSession {
|
||||
fatalError("WorkspaceRegistryTests should not create live terminal sessions.")
|
||||
|
||||
Reference in New Issue
Block a user