Fix tab double-click rename functionality

This commit is contained in:
2026-01-31 23:50:20 +00:00
parent 06743d5e7f
commit 246f4b0b26
5 changed files with 21 additions and 9 deletions

BIN
.DS_Store vendored

Binary file not shown.

Binary file not shown.

View File

@@ -52,6 +52,8 @@ class MainWindowController: NSWindowController {
var settingsWindow: SettingsWindowController! var settingsWindow: SettingsWindowController!
var zoomedPane: TerminalSession? var zoomedPane: TerminalSession?
var preZoomSplitView: NSSplitView? var preZoomSplitView: NSSplitView?
var lastTabClickTime: Date?
var lastTabClickIndex: Int = -1
convenience init() { convenience init() {
let window = NSWindow( let window = NSWindow(
@@ -317,11 +319,6 @@ class MainWindowController: NSWindowController {
tabButton.font = NSFont.systemFont(ofSize: 11) tabButton.font = NSFont.systemFont(ofSize: 11)
tabButton.translatesAutoresizingMaskIntoConstraints = false tabButton.translatesAutoresizingMaskIntoConstraints = false
// Add double-click for rename
let doubleClickGesture = NSClickGestureRecognizer(target: self, action: #selector(tabDoubleClicked(_:)))
doubleClickGesture.numberOfClicksRequired = 2
tabButton.addGestureRecognizer(doubleClickGesture)
// Highlight current tab // Highlight current tab
if index == tabManager.currentIndex { if index == tabManager.currentIndex {
tabButton.contentTintColor = .systemBlue tabButton.contentTintColor = .systemBlue
@@ -421,12 +418,27 @@ class MainWindowController: NSWindowController {
} }
@objc func tabClicked(_ sender: NSButton) { @objc func tabClicked(_ sender: NSButton) {
switchToTab(index: sender.tag) let index = sender.tag
let now = Date()
// Check for double-click (within 0.3 seconds)
if let lastClick = lastTabClickTime,
lastTabClickIndex == index,
now.timeIntervalSince(lastClick) < 0.3 {
// Double-click detected
tabDoubleClicked(sender)
lastTabClickTime = nil
lastTabClickIndex = -1
} else {
// Single click
lastTabClickTime = now
lastTabClickIndex = index
switchToTab(index: index)
}
} }
@objc func tabDoubleClicked(_ sender: NSClickGestureRecognizer) { @objc func tabDoubleClicked(_ sender: NSButton) {
guard let button = sender.view as? NSButton else { return } let index = sender.tag
let index = button.tag
let alert = NSAlert() let alert = NSAlert()
alert.messageText = "Rename Tab" alert.messageText = "Rename Tab"