Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closing tabs while Open Quickly or Command Palette is open is no longer allowed. #1868

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ final class CodeEditWindowController: NSWindowController, NSToolbarDelegate, Obs
@Published var inspectorCollapsed = false
@Published var toolbarCollapsed = false

private var panelOpen = false

var observers: [NSKeyValueObservation] = []

var workspace: WorkspaceDocument?
Expand Down Expand Up @@ -109,20 +111,26 @@ final class CodeEditWindowController: NSWindowController, NSToolbarDelegate, Obs
if let commandPalettePanel {
if commandPalettePanel.isKeyWindow {
commandPalettePanel.close()
self.panelOpen = false
state.reset()
return
} else {
state.reset()
window?.addChildWindow(commandPalettePanel, ordered: .above)
commandPalettePanel.makeKeyAndOrderFront(self)
self.panelOpen = true
}
} else {
let panel = SearchPanel()
self.commandPalettePanel = panel
let contentView = QuickActionsView(state: state, closePalette: panel.close)
let contentView = QuickActionsView(state: state) {
panel.close()
self.panelOpen = false
}
panel.contentView = NSHostingView(rootView: SettingsInjector { contentView })
window?.addChildWindow(panel, ordered: .above)
panel.makeKeyAndOrderFront(self)
self.panelOpen = true
}
}
}
Expand All @@ -132,29 +140,34 @@ final class CodeEditWindowController: NSWindowController, NSToolbarDelegate, Obs
if let quickOpenPanel {
if quickOpenPanel.isKeyWindow {
quickOpenPanel.close()
self.panelOpen = false
return
} else {
window?.addChildWindow(quickOpenPanel, ordered: .above)
quickOpenPanel.makeKeyAndOrderFront(self)
self.panelOpen = true
}
} else {
let panel = SearchPanel()
self.quickOpenPanel = panel

let contentView = OpenQuicklyView(state: state) {
panel.close()
self.panelOpen = false
} openFile: { file in
workspace.editorManager?.openTab(item: file)
}.environmentObject(workspace)

panel.contentView = NSHostingView(rootView: SettingsInjector { contentView })
window?.addChildWindow(panel, ordered: .above)
panel.makeKeyAndOrderFront(self)
self.panelOpen = true
}
}
}

@IBAction func closeCurrentTab(_ sender: Any) {
if self.panelOpen { return }
if (workspace?.editorManager?.activeEditor.tabs ?? []).isEmpty {
self.closeActiveEditor(self)
} else {
Expand Down
5 changes: 4 additions & 1 deletion CodeEdit/Features/Settings/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,17 @@ struct SettingsView: View {

var body: some View {
NavigationSplitView {
List { }
.searchable(text: $searchText, placement: .sidebar, prompt: "Search")
.scrollDisabled(true)
.frame(height: 30)
List(selection: $selectedPage) {
Section {
ForEach(Self.pages) { pageAndSettings in
results(pageAndSettings.page, pageAndSettings.settings)
}
}
}
.searchable(text: $searchText, placement: .sidebar, prompt: "Search")
.navigationSplitViewColumnWidth(215)
} detail: {
Group {
Expand Down
Loading