Repo // Auto-expand candidate UI under certain conditions.

This commit is contained in:
ShikiSuen 2023-08-29 00:11:49 +08:00
parent 3d98e6d974
commit 2c132a4f92
3 changed files with 9 additions and 1 deletions

View File

@ -96,7 +96,8 @@ public class CtlCandidateTDK: CtlCandidate, NSWindowDelegate {
CandidateCellData.unifiedSize = candidateFont.pointSize
guard let delegate = delegate else { return }
Self.thePool = .init(
candidates: delegate.candidatePairs(conv: true), lines: maxLinesPerPage, isExpanded: false,
candidates: delegate.candidatePairs(conv: true), lines: maxLinesPerPage,
isExpanded: delegate.shouldAutoExpandCandidates,
selectionKeys: delegate.selectionKeys, layout: currentLayout.layoutTDK, locale: locale
)
Self.thePool.tooltip = tooltip

View File

@ -79,6 +79,12 @@ extension SessionCtl: InputHandlerDelegate {
extension SessionCtl: CtlCandidateDelegate {
public var isCandidateState: Bool { state.isCandidateContainer }
public var shouldAutoExpandCandidates: Bool {
guard state.type == .ofSymbolTable else { return state.type == .ofAssociates }
return state.node.previous != nil
}
public var isCandidateContextMenuEnabled: Bool {
state.type == .ofCandidates && !clientBundleIdentifier.contains("com.apple.Spotlight")
&& !clientBundleIdentifier.contains("com.raycast.macos")

View File

@ -19,6 +19,7 @@ public protocol CtlCandidateDelegate {
var selectionKeys: String { get }
var isVerticalTyping: Bool { get }
var isCandidateState: Bool { get }
var shouldAutoExpandCandidates: Bool { get }
var isCandidateContextMenuEnabled: Bool { get }
var showReverseLookupResult: Bool { get }
}