Skip to content

Syntax highlight getting lost when jumping down large file #634

Open

Description

@krlawrence

I am writing a book using Asciidoc format. You can find the Asciidoc file here:https://github.com/krlawrence/graph/tree/master/book

I am using MacVim version: 8.0.1420

I have not noticed this problem as much in earlier versions of MacVim and it is not an issue editing the same file on Windows using Gvim.

If I load the file and set the syntax to Asciidoc the highlighting looks fine. However if I then do a search that requires jumping way down the file or if I just manually jump to the end of the file, syntax highlighting is lost. Doing a syntax sync fromstart does not bring it back and setting the syntax back to Asciidoc again only seems to work if I jump back to the top of the file and manually scroll down the file. As soon as I jump down the file again same problem. This seems to have started happening since I updated to this version of MacVim.

My OS is MacOS 10.13.3

I have sometimes seen this behaviour before but never until now encountered a case where doing a syntax sync fromstart does not fix it.

Activity

  1. smiglo commented on Mar 13, 2018

    @smiglo

    I am experiencing the same problem in a very long (>3500 lines) bash file. When scrolling down, at certain line syntax gets lost and is uncoverable by syntax sync fromstart.

    VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Feb 18 2018 04:09:42)
    Included patches: 1-1522
    
  2. FFEVER commented on Jun 21, 2018

    @FFEVER

    The same problem.

  3. eirnym commented on Jun 21, 2018

    @eirnym
    Contributor

    Is there any public examples to check this issue? I have many Python files >3500 lines long but MacVim never looses syntax highlighting with syntax sync fromstart.

  4. FFEVER commented on Jun 21, 2018

    @FFEVER

    I've found my solution.
    :syntax enable will take back the syntax highlight.
    I don't know why but it works.
    (Mine is >5000 lines of scss file.)

    VIM - Vi IMproved 8.1 (2018 May 17, compiled Jun 13 2018 07:24:23)
    macOS version
    Included patches: 1-50
    Compiled by Homebrew
    
  5. krlawrence commented on Jul 9, 2018

    @krlawrence
    Author

    I listed a way to reproduce this in my initial entry above @eirnym . The file needs to be longer than 3,500 lines I think. I see it in files in the order of 40K lines and it is 100% reproducible.

  6. eirnym commented on Jul 9, 2018

    @eirnym
    Contributor

    Got the same issue with a file with very long lines (from a mysql dump sql file). If lines have reasonable length, everything works like a charm even with huge files. If I chop long lines with RE to smaller ones, problem will "magically" gone

  7. eirnym commented on Jul 9, 2018

    @eirnym
    Contributor

    My file was ~3k lines long and after chopping it is about 100k long

  8. lifepillar commented on Aug 20, 2018

    @lifepillar
    Contributor

    Is this a MacVim issue, though? If I open the OP's Asciidoc file in terminal Vim with vim --clean, syntax highlighting is initially on, but if I press G syntax highlighting is turned off. Also, Vim hangs for a couple of seconds when I press G, which makes me believe that something wrong is happening with some regular expression from Asciidoc's syntax file (or Vim's search simply times out).

  9. lifepillar commented on Aug 20, 2018

    @lifepillar
    Contributor

    Try this: open a long file, turn syntax debugging on with :syntime on, then press G. I see this message:

    'redrawtime' exceeded, syntax highlighting disabled 
    

    Use :syntime report for timing details: e.g., matching asciidocLiteralParagraph alone takes over half a second.

    So, the solution is either to increase redrawtime or (better) ask the developer of the Asciidoc syntax file to optimise the syntax file.

  10. krlawrence commented on Oct 28, 2018

    @krlawrence
    Author

    Thanks I will try this. On MacVim I am seeing syntax highlighting get lost a lot more often these days even on small files of many different types. So (for me anyway) it is not limited to Asciidoc files any more.

  11. xiaotianhu commented on Apr 1, 2019

    @xiaotianhu

    I use Macvim ,most of the time it works fine,except with HTML/VUE files;When I'm editing HTML/VUE/CSS files,highlight usually failed when jump with G or Ctrl+f.Really need some help.It troubles a lot

  12. eirnym commented on Apr 1, 2019

    @eirnym
    Contributor

    This issue was with ViM engine all the time. ViM engine cuts what is far away before and far away after the visible screen to speedup highlighting process. In comparison IntelliJ Idea IDEs hold whole AST in the memory and just turn off syntax highlighting for large files.

    To minimize impact of this issue for me, I prefer to have restrictions like listed below.

    • no wrapping
    • lines are not very long (95% at least not longer than visible
    • use as best syntax files for specific highlighting as possible
    • if file could be broken, I prefer to have it in pieces.
    • the better if syntax context is within +- 30-50 lines before and after the visible screen.

    yes, sometimes I read (not edit much, thankfully) files 2Gb+ long with JSON and/or SQL with syntax formatting turned on.

  13. ychin commented on Apr 3, 2019

    @ychin
    Member

    As others have said this is mostly a general issue with Vim's highlighting and there are different ways to solve it including what the previous comment said or using a longer redrawtime. I was mostly curious if there are specific MacVim performance issues but I tried different large files but I couldn't see one that only affects MacVim and not normal Vim. I'm going to close this issue soon unless someone can give a concrete example of this affecting only MacVim.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions