Skip to content

Commit 26e5ed6

Browse files
authored
Merge pull request #2390 from dgageot/board/fix-docker-agent-github-issue-1771-d918d329
fix: make Ctrl+W context-aware to preserve word deletion in editor
2 parents 2ee8d21 + b4343e5 commit 26e5ed6

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

pkg/tui/components/tabbar/tabbar.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,12 @@ func New(maxTitleLen int) *TabBar {
146146
}
147147
}
148148

149+
// SetCloseTabEnabled enables or disables the close-tab key binding.
150+
// When disabled, Ctrl+W passes through to the editor for word deletion.
151+
func (t *TabBar) SetCloseTabEnabled(v bool) {
152+
t.keyMap.CloseTab.SetEnabled(v)
153+
}
154+
149155
// SetWidth sets the available width for the tab bar.
150156
func (t *TabBar) SetWidth(width int) {
151157
t.width = width

pkg/tui/tui.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1804,7 +1804,10 @@ func (m *appModel) handleKeyPress(msg tea.KeyPressMsg) (tea.Model, tea.Cmd) {
18041804

18051805
// Tab bar keys (Ctrl+t, Ctrl+p, Ctrl+n, Ctrl+w) are suppressed during
18061806
// history search so that ctrl+n/ctrl+p cycle through matches instead.
1807+
// Ctrl+w (close tab) is disabled when the editor is focused so that the
1808+
// standard "delete word" shortcut works while typing.
18071809
if !m.leanMode && !m.editor.IsHistorySearchActive() {
1810+
m.tabBar.SetCloseTabEnabled(m.focusedPanel != PanelEditor)
18081811
if cmd := m.tabBar.Update(msg); cmd != nil {
18091812
return m, cmd
18101813
}

0 commit comments

Comments
 (0)