a 'foldmarker' problem with mb

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

a 'foldmarker' problem with mb

koron
Hello Bram and the list.

I have received a report from a Japanese vim user.  It describes about a
'foldmarker' problem under multibyte environment.  Overview of the
problem is that fold don't be created when a character which be able to
appear as trail byte of multibyte-character, is used in 'foldmarker'.

Setting example to represent the problem is:
  set foldmethod=marker foldmarker={,}
(Character '}' appears as trail byte of multibyte-character in CP932
encoding.)

I wrote attached patch to fix this problem.  Please check it.

Regards.
--
MURAOKA Taro <[hidden email]>

diff -c src/fold.c.orig src/fold.c
*** src/fold.c.orig Thu Feb  2 01:43:37 2006
--- src/fold.c Thu Feb  2 01:43:39 2006
***************
*** 3105,3111 ****
  --flp->lvl_next;
  }
  else
!    ++s;
      }
 
      /* The level can't go negative, must be missing a start marker. */
--- 3105,3118 ----
  --flp->lvl_next;
  }
  else
! {
! #ifdef FEAT_MBYTE
!    if (has_mbyte)
! s += (*mb_ptr2len_check)(s);
!    else
! #endif
! ++s;
! }
      }
 
      /* The level can't go negative, must be missing a start marker. */
Reply | Threaded
Open this post in threaded view
|

Re: a 'foldmarker' problem with mb

Bram Moolenaar

Taro Muraoka wrote:

> Hello Bram and the list.
>
> I have received a report from a Japanese vim user.  It describes about a
> 'foldmarker' problem under multibyte environment.  Overview of the
> problem is that fold don't be created when a character which be able to
> appear as trail byte of multibyte-character, is used in 'foldmarker'.
>
> Setting example to represent the problem is:
>   set foldmethod=marker foldmarker={,}
> (Character '}' appears as trail byte of multibyte-character in CP932
> encoding.)
>
> I wrote attached patch to fix this problem.  Please check it.

Thanks, I'll include this in Vim 7.  We can use mb_ptr_adv() to avoid
the #ifdefs.

--
hundred-and-one symptoms of being an internet addict:
225. You sign up for free subscriptions for all the computer magazines

 /// Bram Moolenaar -- [hidden email] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://www.ICCF.nl         ///