From 5405d5a6bdb9b72bb901f8940028ecf743d8089a Mon Sep 17 00:00:00 2001 From: Hayden Hargreaves Date: Thu, 26 Mar 2026 14:15:59 -0700 Subject: [PATCH] fix: added b and B text objects and note about failing case. --- internal/input/keymap.go | 9 +++++++-- internal/textobject/delimiter.go | 3 +++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/internal/input/keymap.go b/internal/input/keymap.go index 38a63ce..6e60516 100644 --- a/internal/input/keymap.go +++ b/internal/input/keymap.go @@ -95,6 +95,8 @@ func NewNormalKeymap() *Keymap { "\"": textobject.Delimiter{Char: '"'}, "'": textobject.Delimiter{Char: '\''}, "`": textobject.Delimiter{Char: '`'}, + "b": textobject.Delimiter{Char: '('}, + "B": textobject.Delimiter{Char: '{'}, }, } } @@ -142,8 +144,9 @@ func NewVisualKeymap() *Keymap { "a": nil, }, textObjects: map[string]action.TextObject{ - "w": textobject.Word{}, - "W": textobject.WORD{}, + "w": textobject.Word{}, + "W": textobject.WORD{}, + // TODO: 's' and 'p' "{": textobject.Delimiter{Char: '{'}, "}": textobject.Delimiter{Char: '}'}, "(": textobject.Delimiter{Char: '('}, @@ -155,6 +158,8 @@ func NewVisualKeymap() *Keymap { "\"": textobject.Delimiter{Char: '"'}, "'": textobject.Delimiter{Char: '\''}, "`": textobject.Delimiter{Char: '`'}, + "b": textobject.Delimiter{Char: '('}, + "B": textobject.Delimiter{Char: '{'}, }, } } diff --git a/internal/textobject/delimiter.go b/internal/textobject/delimiter.go index 5fc67fa..0a1ae3c 100644 --- a/internal/textobject/delimiter.go +++ b/internal/textobject/delimiter.go @@ -47,6 +47,9 @@ type Delimiter struct { } // TODO: This should allow for many lines, not just a single line +// +// BUG: This does not work properly when the cursor is not inside a delimiter. If the cursor +// does not fall inside a delimiter range, it should search forward and find the delimiter. func (to Delimiter) GetRange(m action.Model, cursor core.Position, modifier string) (core.Position, core.Position, core.MotionType) { buf := m.ActiveBuffer() line := buf.Lines[cursor.Line]