File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -84,6 +84,7 @@ if g:better_whitespace_skip_empty_lines == 1
8484endif
8585
8686let s: strip_whitespace_pattern = s: eol_whitespace_pattern
87+ let s: strip_whitelines_pattern = ' \(\n\)\+\%$'
8788if g: show_spaces_that_precede_tabs == 1
8889 let s: eol_whitespace_pattern .= ' \|[' . s: whitespace_chars . ' ]\+\ze[\u0009]'
8990endif
@@ -195,7 +196,11 @@ endif
195196" WARNING: moves the cursor.
196197function ! s: DetectWhitespace (line1, line2)
197198 call cursor (a: line1 , 1 )
198- return search (s: strip_whitespace_pattern , ' cn' , a: line2 )
199+ let found = search (s: strip_whitespace_pattern , ' cn' , a: line2 )
200+ if g: strip_whitelines_at_eof == 1 && a: line2 >= line (' $' )
201+ let found += search (s: strip_whitelines_pattern , ' cn' )
202+ endif
203+ return found
199204endfunction
200205
201206" Removes all extraneous whitespace in the file
@@ -209,7 +214,7 @@ function! s:StripWhitespace(line1, line2)
209214
210215 " Strip empty lines at EOF
211216 if g: strip_whitelines_at_eof == 1 && a: line2 >= line (' $' )
212- silent execute ' %s/\(\n\)\+\%$ //e'
217+ silent execute ' %s/' . s: strip_whitelines_pattern . ' //e'
213218 endif
214219
215220 " Restore the saved search and cursor position
You can’t perform that action at this time.
0 commit comments