]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
updated for version 7.3.750 v7.3.750
authorBram Moolenaar <Bram@vim.org>
Wed, 5 Dec 2012 16:03:22 +0000 (17:03 +0100)
committerBram Moolenaar <Bram@vim.org>
Wed, 5 Dec 2012 16:03:22 +0000 (17:03 +0100)
Problem:    The justify macro does not always work correctly.
Solution:   Fix off-by-one error (James McCoy)

runtime/macros/justify.vim
src/version.c

index aa4a9ca585beeea9c0397bc86bc6cbce4fcac8de..4ef3bf95fa32deea98bf40575ae94d440a4b92e3 100644 (file)
@@ -1,4 +1,4 @@
-" Function to left and rigt align text.
+" 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,18 +256,17 @@ function! Justify(...) range
        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'))
+       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 = strlen(substitute(str, '.', 'x', 'g')) - str_n
+       let join_n = strdisplaywidth(str) - 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
+       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
index c551421f0de12de2fe236e233924f6d4e5f5f913..2987755fc2158d2aa9b683227bd92b6b74876e89 100644 (file)
@@ -725,6 +725,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    750,
 /**/
     749,
 /**/