From 0512f898c5ce10f2eef75e405440d721d4ed6807 Mon Sep 17 00:00:00 2001 From: jluehrs2 Date: Wed, 7 May 2008 06:06:30 -0500 Subject: simplify the length calculation by quite a bit --- vim/plugin/textobj.vim | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/vim/plugin/textobj.vim b/vim/plugin/textobj.vim index 0cda57a..85381df 100644 --- a/vim/plugin/textobj.vim +++ b/vim/plugin/textobj.vim @@ -15,15 +15,11 @@ function Textobj(char, callback) if startline == endline let objlength = endcol - startcol + 1 else - let lines = getline(startline + 1, endline - 1) - let lines = [strpart(getline(startline), startcol - 1)] + - \ lines + - \ [strpart(getline(endline), 0, endcol)] let objlength = 0 - for line in lines - let objlength += strlen(line) + 1 - endfor - let objlength -= 1 + if endline - startline > 1 + exe 'let objlength += '.join(map(getline(startline + 1, endline - 1), 'strlen(v:val) + 1'), '+') + endif + let objlength += endcol + strlen(getline(startline)) - startcol + 2 endif let whichwrap = &whichwrap set whichwrap+=s -- cgit v1.2.3