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