Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntax highlighting failure in GVim on Windows #1918

Closed
skywind3000 opened this issue Aug 2, 2017 · 13 comments
Closed

Syntax highlighting failure in GVim on Windows #1918

skywind3000 opened this issue Aug 2, 2017 · 13 comments

Comments

@skywind3000
Copy link

GVim version: 8.0.839 x86
Windows: Win 10 x64

GVim 8.0.636 works fine, but all the highlighting disappeared when I move around the cursor in GVim 8.0.839. Console mode is also fine, only the GVim:

syntax_error

command to reproduce:

gvim -N -u ..\initrc.vim d:/acm/github/vim/asc/menu.vim

content of initrc.vim:

set nocompatible
syntax on

If I enter these two line above in the vim, the bug will not be reproduced, they must be in initrc.vim and load before gvim startup.

@markonm
Copy link

markonm commented Sep 16, 2017

I can reproduce similar Vim script syntax fail on 8.0.1067 on Win 10 x64. In my case syntax breaks in gVim and CMD's Vim.

Steps to reproduce:

  1. gvim -u NONE -i NONE -N "+so $VIMRUNTIME/plugin/matchparen.vim" "+syntax on" reproduce.vim
  2. type the following in normal mode ffyiWjviwpk
  3. syntax disappears

reproduce.vim

let a = foo()
let b = baz

If I disable matchparen with let g:loaded_matchparen = 1, syntax will not break

Breakage was introduced in patch 8.0.0647. Before that commit I cannot reproduce.

@skywind3000
Copy link
Author

Still exists in 8.0.1118

@mattn
Copy link
Member

mattn commented Sep 17, 2017

@xtal8 I also use Win 10 x64. But I don't reproduce it.

@markonm
Copy link

markonm commented Sep 17, 2017

@mattn Do you use x64 gVim also? I can't reproduce on x86. My version is downloaded from here https://github.com/vim/vim-win32-installer/releases

@mattn
Copy link
Member

mattn commented Sep 17, 2017

Yes, I use x64. But I built vim with mingw compiler.

@markonm
Copy link

markonm commented Sep 17, 2017

Could you try to reproduce with gvim_8.0.1118_x64.zip from that link?

@skywind3000
Copy link
Author

skywind3000 commented Sep 17, 2017

I always download gvim from
https://github.com/vim/vim-win32-installer/releases

And both gvim_8.0.1118_x64.zip and gvim_8.0.1118_x86.zip downloaded from
can reproduce this problem:

  1. download my menu.vim from
    https://github.com/skywind3000/vim/blob/master/asc/menu.vim

  2. open menu.vim and

:normal gg$
  1. move the cursor up and down by 'j' and 'k'

and than, You can encounter the issue in both gvim.exe and vim.exe.

attachment: menu.vim
menu.zip

@markonm
Copy link

markonm commented Sep 17, 2017

I can reproduce issue with menu.vim only on gvim_8.0.1118_x64.zip. When I try to reproduce on x86. there's no syntax breakage.

@skywind3000
Copy link
Author

strange, on my laptop:

gvim installed by gvim_8.0.1118_x86.exe has the problem.
gvim extracted from gvim_8.0.1118_x86.zip doesn't have the problem.

@chrisbra
Copy link
Member

strange, on my laptop:

gvim installed by gvim_8.0.1118_x86.exe has the problem.
gvim extracted from gvim_8.0.1118_x86.zip doesn't have the problem.

Just checked it, could not reproduce it with either one.

@mattn
Copy link
Member

mattn commented Sep 22, 2017

This patch will fix the issue.

diff --git a/src/syntax.c b/src/syntax.c
index 6361bd7aa..0d5af0cc3 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -6573,9 +6573,14 @@ syn_get_id(
     else if (wp->w_buffer == syn_buf
 	    && lnum == current_lnum
 	    && col > current_col)
+    {
+	/* reset syn_tm here since this is not highlighting */
+	syn_tm = NULL;
+
 	/* next_match may not be correct when moving around, e.g. with the
 	 * "skip" expression in searchpair() */
 	next_match_idx = -1;
+    }
 
     (void)get_syntax_attr(col, spellp, keep_state);
 

syn_tm is set when start syntax to disable heavy syntax. matchparen call f_synstack(). And it call syn_get_id(), syn_get_attr(). This doesn't call syntax_call (this is correct pass). i.e. syn_tm is used unintentionally which is already timed-out.

@mattn
Copy link
Member

mattn commented Sep 22, 2017

@brammool This should be temporary updating like below?

diff --git a/src/syntax.c b/src/syntax.c
index 6361bd7aa..950ea7153 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -6564,6 +6564,8 @@ syn_get_id(
     int		*spellp,     /* return: can do spell checking */
     int		keep_state)  /* keep state of char at "col" */
 {
+    proftime_T	*save_tm = syn_tm;
+
     /* When the position is not after the current position and in the same
      * line of the same buffer, need to restart parsing. */
     if (wp->w_buffer != syn_buf
@@ -6573,12 +6575,19 @@ syn_get_id(
     else if (wp->w_buffer == syn_buf
 	    && lnum == current_lnum
 	    && col > current_col)
+    {
+	/* reset syn_tm here since this is not highlighting */
+	syn_tm = NULL;
+
 	/* next_match may not be correct when moving around, e.g. with the
 	 * "skip" expression in searchpair() */
 	next_match_idx = -1;
+    }
 
     (void)get_syntax_attr(col, spellp, keep_state);
 
+    syn_tm = save_tm;
+
     return (trans ? current_trans_id : current_id);
 }
 

mattn added a commit to mattn/vim that referenced this issue Sep 22, 2017
mattn added a commit to mattn/vim that referenced this issue Sep 22, 2017
@brammool
Copy link
Contributor

Fixed by 8.0.1133

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants