aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2018-07-20 22:00:45 +1200
committerTom Ryder <tom@sanctum.geek.nz>2018-07-20 22:00:45 +1200
commite214262c3b5a00070025d4e45ca08f0f3d2b8148 (patch)
tree826539d63cae879ffbe45e1519336cdd73558d97
parentMerge branch 'hotfix/v2.0.1' into develop (diff)
parentBump VERSION (diff)
downloadvim-strip-trailing-whitespace-e214262c3b5a00070025d4e45ca08f0f3d2b8148.tar.gz
vim-strip-trailing-whitespace-e214262c3b5a00070025d4e45ca08f0f3d2b8148.zip
Merge branch 'hotfix/v2.0.2' into develop
* hotfix/v2.0.2: Bump VERSION Don't report deleted lines as trimmed
-rw-r--r--VERSION2
-rw-r--r--plugin/strip_trailing_whitespace.vim20
2 files changed, 14 insertions, 8 deletions
diff --git a/VERSION b/VERSION
index 38f77a6..e9307ca 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.0.1
+2.0.2
diff --git a/plugin/strip_trailing_whitespace.vim b/plugin/strip_trailing_whitespace.vim
index ed9ad66..207863a 100644
--- a/plugin/strip_trailing_whitespace.vim
+++ b/plugin/strip_trailing_whitespace.vim
@@ -22,22 +22,28 @@ function s:Strip(start, end) abort
let l:line = line('.')
let l:col = col('.')
- " Strip horizontal space
- let l:horizontal = s:StripHorizontal(a:start, a:end)
- let l:msg = l:horizontal.' trimmed'
- let l:changed = l:horizontal > 0
+ " Whether we made changes
+ let l:changed = 0
- " If we're going to the end, strip vertical space
+ " If we're going to the end, strip vertical space; we do this first so we
+ " don't end up reporting having trimmed lines that we deleted
if a:end == line('$')
let l:vertical = s:StripVertical()
- let l:msg = l:msg.', '.l:vertical.' deleted'
let l:changed = l:changed || l:vertical > 0
endif
+ " Strip horizontal space
+ let l:horizontal = s:StripHorizontal(a:start, a:end)
+ let l:changed = l:changed || l:horizontal > 0
+
" Return the cursor
call s:Cursor(l:line, l:col)
" Report what changed
+ let l:msg = l:horizontal.' trimmed'
+ if exists('l:vertical')
+ let l:msg = l:msg.', '.l:vertical.' deleted'
+ endif
echomsg l:msg
" Return whether anything changed
@@ -53,7 +59,7 @@ function s:StripHorizontal(start, end) abort
" Iterate through buffer
let l:num = a:start
- while l:num <= a:end
+ while l:num <= line('$') && l:num <= a:end
" If the line has trailing whitespace, strip it off and bump the count
let l:line = getline(l:num)