macos: show pwd for jump options
parent
b30e94c0ec
commit
1fd3f27e26
|
|
@ -3,6 +3,7 @@ import SwiftUI
|
|||
struct CommandOption: Identifiable, Hashable {
|
||||
let id = UUID()
|
||||
let title: String
|
||||
let subtitle: String?
|
||||
let description: String?
|
||||
let symbols: [String]?
|
||||
let leadingIcon: String?
|
||||
|
|
@ -13,6 +14,7 @@ struct CommandOption: Identifiable, Hashable {
|
|||
|
||||
init(
|
||||
title: String,
|
||||
subtitle: String? = nil,
|
||||
description: String? = nil,
|
||||
symbols: [String]? = nil,
|
||||
leadingIcon: String? = nil,
|
||||
|
|
@ -22,6 +24,7 @@ struct CommandOption: Identifiable, Hashable {
|
|||
action: @escaping () -> Void
|
||||
) {
|
||||
self.title = title
|
||||
self.subtitle = subtitle
|
||||
self.description = description
|
||||
self.symbols = symbols
|
||||
self.leadingIcon = leadingIcon
|
||||
|
|
@ -55,7 +58,10 @@ struct CommandPaletteView: View {
|
|||
if query.isEmpty {
|
||||
return options
|
||||
} else {
|
||||
return options.filter { $0.title.localizedCaseInsensitiveContains(query) }
|
||||
return options.filter {
|
||||
$0.title.localizedCaseInsensitiveContains(query) ||
|
||||
($0.subtitle?.localizedCaseInsensitiveContains(query) ?? false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -298,8 +304,16 @@ fileprivate struct CommandRow: View {
|
|||
.font(.system(size: 14, weight: .medium))
|
||||
}
|
||||
|
||||
Text(option.title)
|
||||
.fontWeight(option.emphasis ? .medium : .regular)
|
||||
VStack(alignment: .leading, spacing: 2) {
|
||||
Text(option.title)
|
||||
.fontWeight(option.emphasis ? .medium : .regular)
|
||||
|
||||
if let subtitle = option.subtitle {
|
||||
Text(subtitle)
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
}
|
||||
|
||||
Spacer()
|
||||
|
||||
|
|
|
|||
|
|
@ -142,10 +142,16 @@ struct TerminalCommandPaletteView: View {
|
|||
return controller.surfaceTree.map { surface in
|
||||
let title = surface.title.isEmpty ? window.title : surface.title
|
||||
let displayTitle = title.isEmpty ? "Untitled" : title
|
||||
let pwd = surface.pwd?.abbreviatedPath
|
||||
let subtitle: String? = if let pwd, !displayTitle.contains(pwd) {
|
||||
pwd
|
||||
} else {
|
||||
nil
|
||||
}
|
||||
|
||||
return CommandOption(
|
||||
title: "Focus: \(displayTitle)",
|
||||
description: surface.pwd?.abbreviatedPath,
|
||||
subtitle: subtitle,
|
||||
leadingIcon: "rectangle.on.rectangle",
|
||||
leadingColor: displayColor?.displayColor.map { Color($0) }
|
||||
) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue