Skip to content

Commit

Permalink
Closing tabs while Open Quickly or Command Palette is open is no long…
Browse files Browse the repository at this point in the history
…er allowed. (#1868)

* scrolling disabled in the settings sidebar

* the searchbar is now pinned to the top of the sidebar

* using height instead of maxHeight

* Opening Open Quickly or Command Palette will no longer allow closing of editor tabs.

* Apply suggestions from code review

Co-authored-by: Austin Condiff <[email protected]>

---------

Co-authored-by: Tom Ludwig <[email protected]>
Co-authored-by: Austin Condiff <[email protected]>
  • Loading branch information
3 people authored Sep 28, 2024
1 parent bda9940 commit 1255659
Showing 1 changed file with 14 additions and 1 deletion.
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

0 comments on commit 1255659

Please sign in to comment.