patch 9.0.2017: linebreak applies for leading whitespace

Problem:  linebreak applies for leading whitespace
Solution: only apply linebreak, once we have found non-breakat chars in
          the line

closes: #13228
closes: #13243

Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/testdir/test_listlbr.vim b/src/testdir/test_listlbr.vim
index e583e48..bcbd886 100644
--- a/src/testdir/test_listlbr.vim
+++ b/src/testdir/test_listlbr.vim
@@ -372,4 +372,19 @@
   call s:close_windows()
 endfunc
 
+func Test_linebreak_no_break_after_whitespace_only()
+  call s:test_windows('setl ts=4 linebreak wrap')
+  call setline(1, "\tabcdefghijklmnopqrstuvwxyz" ..
+        \ "abcdefghijklmnopqrstuvwxyz")
+  let lines = s:screen_lines([1, 4], winwidth(0))
+  let expect = [
+\ "    abcdefghijklmnop",
+\ "qrstuvwxyzabcdefghij",
+\ "klmnopqrstuvwxyz    ",
+\ "~                   ",
+\ ]
+  call s:compare_lines(expect, lines)
+  call s:close_windows()
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab