martanne / vis

A vi-like editor based on Plan 9's structural regular expressions
Other
4.23k stars 256 forks source link

Improve behavior of inner text objects when working linewise #881

Closed autumn-canfield closed 1 year ago

autumn-canfield commented 3 years ago

Currently inner and outer text objects both behave exactly the same for linewise operations. I think it would make a lot more sense to limit inner text objects to only the lines contained within the range. So for example right now >i{ and >a{ from with in this if

if (linewise && (a->textobj->type & TEXTOBJECT_DELIMITED_INNER)) {
r.start = text_line_next(txt, r.start);
r.end = text_line_prev(txt, r.end);
}

both result in

    if (linewise && (a->textobj->type & TEXTOBJECT_DELIMITED_INNER)) {
    r.start = text_line_next(txt, r.start);
    r.end = text_line_prev(txt, r.end);
    }

With these changes >i{ would only affect the lines contained inside like so:

if (linewise && (a->textobj->type & TEXTOBJECT_DELIMITED_INNER)) {
    r.start = text_line_next(txt, r.start);
    r.end = text_line_prev(txt, r.end);
}
moesasji commented 3 years ago

This patch works for me and makes vis behave the same as vim on this example for these two motions.

rnpnr commented 1 year ago

Applied, thanks for the patch!