Skip to content

Finding “\n” using regular expression is very slow in a file containing a lot of lines #41503

Closed

Description

@EFanZh
  • VSCode Version: 1.19.2
  • OS Version: Windows 7 64-bit

Steps to Reproduce:

  1. Create a file with 10000 lines.
  2. Type \n in the find widget and turn on “Use Regular Expression”.

Does this issue occur when all extensions are disabled?: Yes

Also, searching for ^ and $ is still fast.

Activity

  1. changed the title [-]Find “\n” using regular expression is very slow in a file containing a lot of lines[/-] [+]Finding “\n” using regular expression is very slow in a file containing a lot of lines[/+] on Jan 12, 2018
  2. alexdima commented on Jan 18, 2018

    @alexdima
    Member

    On my machine, searching for \n in a file with 25k lines is dominated by:

    • (40ms) actually finding \n 20k times
    • (67ms) creating 20k decorations

    image

    I can look into optimizing this specific search (~40ms), as searching for \n is trivial.

  3. EFanZh commented on Jan 19, 2018

    @EFanZh
    ContributorAuthor

    alexandrudima It seems that I can only reproduce this issue on Windows platform. It is fast on my Linux PC. It takes me 4 to 20 seconds to search for \n on Windows, depending on the hardwares.

  4. EFanZh commented on Jan 23, 2018

    @EFanZh
    ContributorAuthor

    alexandrudima Did you test it on Windows? I couldn’t reproduce it on Linux, so I think this is a platform-specific issue.

  5. EFanZh commented on Jan 24, 2018

    @EFanZh
    ContributorAuthor

    alexandrudima I have tested your fix on version 1.20.0-insider (84991c4). Searching for \n is fast on Windows now, but searching for .\n is still very slow. Still, this problem only appears on Windows.

  6. locked and limited conversation to collaborators on Mar 8, 2018
  7. added a commit that references this issue on Sep 6, 2026
    139996a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

editor-find

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions