Guess what? Fixed more bugs...
This commit is contained in:
@@ -9,8 +9,6 @@ import SwiftUI
|
||||
|
||||
struct InputBar: View {
|
||||
@Binding var text: String
|
||||
@Binding var commandHistory: [String]
|
||||
@Binding var historyIndex: Int
|
||||
let isGenerating: Bool
|
||||
let mcpStatus: String?
|
||||
let onlineMode: Bool
|
||||
@@ -81,44 +79,26 @@ struct InputBar: View {
|
||||
.onChange(of: text) {
|
||||
showCommandDropdown = text.hasPrefix("/")
|
||||
selectedSuggestionIndex = 0
|
||||
// Reset history index when user types
|
||||
historyIndex = commandHistory.count
|
||||
}
|
||||
#if os(macOS)
|
||||
.onKeyPress(.upArrow) {
|
||||
// If command dropdown is showing, navigate dropdown
|
||||
if showCommandDropdown {
|
||||
if selectedSuggestionIndex > 0 {
|
||||
selectedSuggestionIndex -= 1
|
||||
}
|
||||
// Navigate command dropdown
|
||||
if showCommandDropdown && selectedSuggestionIndex > 0 {
|
||||
selectedSuggestionIndex -= 1
|
||||
return .handled
|
||||
}
|
||||
// Otherwise, navigate command history
|
||||
if historyIndex > 0 {
|
||||
historyIndex -= 1
|
||||
text = commandHistory[historyIndex]
|
||||
}
|
||||
return .handled
|
||||
return .ignored
|
||||
}
|
||||
.onKeyPress(.downArrow) {
|
||||
// If command dropdown is showing, navigate dropdown
|
||||
// Navigate command dropdown
|
||||
if showCommandDropdown {
|
||||
let count = CommandSuggestionsView.filteredCommands(for: text).count
|
||||
if selectedSuggestionIndex < count - 1 {
|
||||
selectedSuggestionIndex += 1
|
||||
return .handled
|
||||
}
|
||||
return .handled
|
||||
}
|
||||
// Otherwise, navigate command history
|
||||
if historyIndex < commandHistory.count - 1 {
|
||||
historyIndex += 1
|
||||
text = commandHistory[historyIndex]
|
||||
} else if historyIndex == commandHistory.count - 1 {
|
||||
// At the end of history, clear text and move to "new" position
|
||||
historyIndex = commandHistory.count
|
||||
text = ""
|
||||
}
|
||||
return .handled
|
||||
return .ignored
|
||||
}
|
||||
.onKeyPress(.escape) {
|
||||
// If command dropdown is showing, close it
|
||||
@@ -352,8 +332,6 @@ struct CommandSuggestionsView: View {
|
||||
Spacer()
|
||||
InputBar(
|
||||
text: .constant(""),
|
||||
commandHistory: .constant([]),
|
||||
historyIndex: .constant(0),
|
||||
isGenerating: false,
|
||||
mcpStatus: "📁 Files",
|
||||
onlineMode: true,
|
||||
|
||||
Reference in New Issue
Block a user