fix: added b and B text objects and note about failing case.
All checks were successful
Run Test Suite / test (push) Successful in 47s

This commit is contained in:
Hayden Hargreaves 2026-03-26 14:15:59 -07:00
parent aa156971ad
commit 5405d5a6bd
2 changed files with 10 additions and 2 deletions

View File

@ -95,6 +95,8 @@ func NewNormalKeymap() *Keymap {
"\"": textobject.Delimiter{Char: '"'},
"'": textobject.Delimiter{Char: '\''},
"`": textobject.Delimiter{Char: '`'},
"b": textobject.Delimiter{Char: '('},
"B": textobject.Delimiter{Char: '{'},
},
}
}
@ -144,6 +146,7 @@ func NewVisualKeymap() *Keymap {
textObjects: map[string]action.TextObject{
"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: '{'},
},
}
}

View File

@ -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]