Blob Blame History Raw
To: vim_dev@googlegroups.com
Subject: Patch 7.3.750
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 7.3.750
Problem:    The justify macro does not always work correctly.
Solution:   Fix off-by-one error (James McCoy)
Files:	    runtime/macros/justify.vim


*** ../vim-7.3.749/runtime/macros/justify.vim	2010-08-15 21:57:19.000000000 +0200
--- runtime/macros/justify.vim	2012-12-05 16:58:40.000000000 +0100
***************
*** 1,4 ****
! " Function to left and rigt align text.
  "
  " Written by:	Preben "Peppe" Guldberg <c928400@student.dtu.dk>
  " Created:	980806 14:13 (or around that time anyway)
--- 1,4 ----
! " Function to left and right align text.
  "
  " Written by:	Preben "Peppe" Guldberg <c928400@student.dtu.dk>
  " Created:	980806 14:13 (or around that time anyway)
***************
*** 256,273 ****
  	let str = substitute(str, '\s\+$', '', '')
  	let str = substitute(str, '^\s\+', '', '')
  	let str = substitute(str, '\s\+', ' ', 'g')
! 	" Use substitute() hack to get strlen in characters instead of bytes
! 	let str_n = strlen(substitute(str, '.', 'x', 'g'))
  
  	" Possible addition of space after punctuation
  	if exists("join_str")
  	    let str = substitute(str, join_str, '\1 ', 'g')
  	endif
! 	let join_n = strlen(substitute(str, '.', 'x', 'g')) - str_n
  
  	" Can extraspaces be added?
  	" Note that str_n may be less than strlen(str) [joinspaces above]
! 	if strlen(substitute(str, '.', 'x', 'g')) < tw - indent_n && str_n > 0
  	    " How many spaces should be added
  	    let s_add = tw - str_n - indent_n - join_n
  	    let s_nr  = strlen(substitute(str, '\S', '', 'g') ) - join_n
--- 256,272 ----
  	let str = substitute(str, '\s\+$', '', '')
  	let str = substitute(str, '^\s\+', '', '')
  	let str = substitute(str, '\s\+', ' ', 'g')
! 	let str_n = strdisplaywidth(str)
  
  	" Possible addition of space after punctuation
  	if exists("join_str")
  	    let str = substitute(str, join_str, '\1 ', 'g')
  	endif
! 	let join_n = strdisplaywidth(str) - str_n
  
  	" Can extraspaces be added?
  	" Note that str_n may be less than strlen(str) [joinspaces above]
! 	if strdisplaywidth(str) <= tw - indent_n && str_n > 0
  	    " How many spaces should be added
  	    let s_add = tw - str_n - indent_n - join_n
  	    let s_nr  = strlen(substitute(str, '\S', '', 'g') ) - join_n
*** ../vim-7.3.749/src/version.c	2012-12-05 16:30:03.000000000 +0100
--- src/version.c	2012-12-05 17:01:02.000000000 +0100
***************
*** 727,728 ****
--- 727,730 ----
  {   /* Add new patch number below this line */
+ /**/
+     750,
  /**/

-- 
To be rich is not the end, but only a change of worries.

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///