summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2012-12-05 17:03:22 +0100
committerBram Moolenaar <Bram@vim.org>2012-12-05 17:03:22 +0100
commit57e4ee4d383e8aaf765635cd2fe2a3edbd72d9bd (patch)
tree3312b73fdbd74b23fb9d52c7418b7345b663f638
parenta54bf400174df9f4a35013da140e537fdb24153a (diff)
updated for version 7.3.750v7.3.750
Problem: The justify macro does not always work correctly. Solution: Fix off-by-one error (James McCoy)
-rw-r--r--runtime/macros/justify.vim9
-rw-r--r--src/version.c2
2 files changed, 6 insertions, 5 deletions
diff --git a/runtime/macros/justify.vim b/runtime/macros/justify.vim
index aa4a9ca585..4ef3bf95fa 100644
--- a/runtime/macros/justify.vim
+++ b/runtime/macros/justify.vim
@@ -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
diff --git a/src/version.c b/src/version.c
index c551421f0d..2987755fc2 100644
--- a/src/version.c
+++ b/src/version.c
@@ -726,6 +726,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 750,
+/**/
749,
/**/
748,