diff src/testdir/test_textformat.vim @ 15440:5ecac7734184 v8.1.0728

patch 8.1.0728: cannot avoid breaking after a single space. commit https://github.com/vim/vim/commit/c3c3158756ae074052b0db2a3e3a7ba192df5330 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Jan 11 22:15:05 2019 +0100 patch 8.1.0728: cannot avoid breaking after a single space. Problem: Cannot avoid breaking after a single space. Solution: Add the 'p' flag to 'formatoptions'. (Tom Ryder)
author Bram Moolenaar <Bram@vim.org>
date Fri, 11 Jan 2019 22:30:06 +0100
parents fe428bee74b3
children 50c0a9fb07ae
line wrap: on
line diff
--- a/src/testdir/test_textformat.vim
+++ b/src/testdir/test_textformat.vim
@@ -163,6 +163,32 @@ func Test_text_format()
 	      \ '# 1 xxxxx',
 	      \ '#   foobar'], getline(1, 2))
 
+  " Test the 'p' flag for 'formatoptions'
+  " First test without the flag: that it will break "Mr. Feynman" at the space
+  normal ggdG
+  setl tw=28 fo=tcq
+  call setline('.', 'Surely you''re joking, Mr. Feynman!')
+  normal gqq
+  call assert_equal([
+              \ 'Surely you''re joking, Mr.',
+              \ 'Feynman!'], getline(1, 2))
+  " Now test with the flag: that it will push the name with the title onto the
+  " next line
+  normal ggdG
+  setl fo+=p
+  call setline('.', 'Surely you''re joking, Mr. Feynman!')
+  normal gqq
+  call assert_equal([
+              \ 'Surely you''re joking,',
+              \ 'Mr. Feynman!'], getline(1, 2))
+  " Ensure that it will still break if two spaces are entered
+  normal ggdG
+  call setline('.', 'Surely you''re joking, Mr.  Feynman!')
+  normal gqq
+  call assert_equal([
+              \ 'Surely you''re joking, Mr.',
+              \ 'Feynman!'], getline(1, 2))
+
   setl ai& tw& fo& si& comments&
   enew!
 endfunc