Skip to content
Open
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions CodeApp/Managers/TerminalInstance.swift
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,22 @@ class TerminalInstance: NSObject, WKScriptMessageHandler, WKNavigationDelegate {
}
openSharedFilesApp(urlString: dir)
self.readLine()
case let x where x.hasPrefix("history"):
let args = x.components(separatedBy: " ")
if args.count == 2 && args[1] == "-c" {
// Clear command history stored in local-echo.js
// This accesses the HistoryController instance (localEcho.history)
// to reset both the entries array and cursor position
executeScript("localEcho.history.entries = []; localEcho.history.cursor = 0;")
self.readLine()
} else {
// Display history - pass to ios_system for default behavior
executor?.dispatch(command: x, isInteractive: false) { _ in
DispatchQueue.main.async {
self.readLine()
}
}
}
Comment on lines 330 to 333
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use fallthrough here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion! Changed to use fallthrough in commit 8ff488f. This eliminates code duplication and makes it cleaner.

default:
let command = result["Input"] as! String
// guard command.count > 0 else {
Expand Down