Karsten Hopp b1cb5a
To: vim_dev@googlegroups.com
Karsten Hopp b1cb5a
Subject: Patch 7.3.750
Karsten Hopp b1cb5a
Fcc: outbox
Karsten Hopp b1cb5a
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp b1cb5a
Mime-Version: 1.0
Karsten Hopp b1cb5a
Content-Type: text/plain; charset=UTF-8
Karsten Hopp b1cb5a
Content-Transfer-Encoding: 8bit
Karsten Hopp b1cb5a
------------
Karsten Hopp b1cb5a
Karsten Hopp b1cb5a
Patch 7.3.750
Karsten Hopp b1cb5a
Problem:    The justify macro does not always work correctly.
Karsten Hopp b1cb5a
Solution:   Fix off-by-one error (James McCoy)
Karsten Hopp b1cb5a
Files:	    runtime/macros/justify.vim
Karsten Hopp b1cb5a
Karsten Hopp b1cb5a
Karsten Hopp b1cb5a
*** ../vim-7.3.749/runtime/macros/justify.vim	2010-08-15 21:57:19.000000000 +0200
Karsten Hopp b1cb5a
--- runtime/macros/justify.vim	2012-12-05 16:58:40.000000000 +0100
Karsten Hopp b1cb5a
***************
Karsten Hopp b1cb5a
*** 1,4 ****
Karsten Hopp b1cb5a
! " Function to left and rigt align text.
Karsten Hopp b1cb5a
  "
Karsten Hopp b1cb5a
  " Written by:	Preben "Peppe" Guldberg <c928400@student.dtu.dk>
Karsten Hopp b1cb5a
  " Created:	980806 14:13 (or around that time anyway)
Karsten Hopp b1cb5a
--- 1,4 ----
Karsten Hopp b1cb5a
! " Function to left and right align text.
Karsten Hopp b1cb5a
  "
Karsten Hopp b1cb5a
  " Written by:	Preben "Peppe" Guldberg <c928400@student.dtu.dk>
Karsten Hopp b1cb5a
  " Created:	980806 14:13 (or around that time anyway)
Karsten Hopp b1cb5a
***************
Karsten Hopp b1cb5a
*** 256,273 ****
Karsten Hopp b1cb5a
  	let str = substitute(str, '\s\+$', '', '')
Karsten Hopp b1cb5a
  	let str = substitute(str, '^\s\+', '', '')
Karsten Hopp b1cb5a
  	let str = substitute(str, '\s\+', ' ', 'g')
Karsten Hopp b1cb5a
! 	" Use substitute() hack to get strlen in characters instead of bytes
Karsten Hopp b1cb5a
! 	let str_n = strlen(substitute(str, '.', 'x', 'g'))
Karsten Hopp b1cb5a
  
Karsten Hopp b1cb5a
  	" Possible addition of space after punctuation
Karsten Hopp b1cb5a
  	if exists("join_str")
Karsten Hopp b1cb5a
  	    let str = substitute(str, join_str, '\1 ', 'g')
Karsten Hopp b1cb5a
  	endif
Karsten Hopp b1cb5a
! 	let join_n = strlen(substitute(str, '.', 'x', 'g')) - str_n
Karsten Hopp b1cb5a
  
Karsten Hopp b1cb5a
  	" Can extraspaces be added?
Karsten Hopp b1cb5a
  	" Note that str_n may be less than strlen(str) [joinspaces above]
Karsten Hopp b1cb5a
! 	if strlen(substitute(str, '.', 'x', 'g')) < tw - indent_n && str_n > 0
Karsten Hopp b1cb5a
  	    " How many spaces should be added
Karsten Hopp b1cb5a
  	    let s_add = tw - str_n - indent_n - join_n
Karsten Hopp b1cb5a
  	    let s_nr  = strlen(substitute(str, '\S', '', 'g') ) - join_n
Karsten Hopp b1cb5a
--- 256,272 ----
Karsten Hopp b1cb5a
  	let str = substitute(str, '\s\+$', '', '')
Karsten Hopp b1cb5a
  	let str = substitute(str, '^\s\+', '', '')
Karsten Hopp b1cb5a
  	let str = substitute(str, '\s\+', ' ', 'g')
Karsten Hopp b1cb5a
! 	let str_n = strdisplaywidth(str)
Karsten Hopp b1cb5a
  
Karsten Hopp b1cb5a
  	" Possible addition of space after punctuation
Karsten Hopp b1cb5a
  	if exists("join_str")
Karsten Hopp b1cb5a
  	    let str = substitute(str, join_str, '\1 ', 'g')
Karsten Hopp b1cb5a
  	endif
Karsten Hopp b1cb5a
! 	let join_n = strdisplaywidth(str) - str_n
Karsten Hopp b1cb5a
  
Karsten Hopp b1cb5a
  	" Can extraspaces be added?
Karsten Hopp b1cb5a
  	" Note that str_n may be less than strlen(str) [joinspaces above]
Karsten Hopp b1cb5a
! 	if strdisplaywidth(str) <= tw - indent_n && str_n > 0
Karsten Hopp b1cb5a
  	    " How many spaces should be added
Karsten Hopp b1cb5a
  	    let s_add = tw - str_n - indent_n - join_n
Karsten Hopp b1cb5a
  	    let s_nr  = strlen(substitute(str, '\S', '', 'g') ) - join_n
Karsten Hopp b1cb5a
*** ../vim-7.3.749/src/version.c	2012-12-05 16:30:03.000000000 +0100
Karsten Hopp b1cb5a
--- src/version.c	2012-12-05 17:01:02.000000000 +0100
Karsten Hopp b1cb5a
***************
Karsten Hopp b1cb5a
*** 727,728 ****
Karsten Hopp b1cb5a
--- 727,730 ----
Karsten Hopp b1cb5a
  {   /* Add new patch number below this line */
Karsten Hopp b1cb5a
+ /**/
Karsten Hopp b1cb5a
+     750,
Karsten Hopp b1cb5a
  /**/
Karsten Hopp b1cb5a
Karsten Hopp b1cb5a
-- 
Karsten Hopp b1cb5a
To be rich is not the end, but only a change of worries.
Karsten Hopp b1cb5a
Karsten Hopp b1cb5a
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp b1cb5a
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp b1cb5a
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp b1cb5a
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///