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

Languages firstLine-detection quietly fails if match need more than 100 characters #77332

Closed
PerMildner opened this issue Jul 13, 2019 · 3 comments
Assignees
Labels
feature-request Request for new features or functionality verified Verification succeeded
Milestone

Comments

@PerMildner
Copy link

  • VSCode Version: Version 1.36.1
  • OS Version: macOS 10.14.5

Steps to Reproduce:

  1. Create a file with a first line that is longer that 100 characters that matches a firstLine regexp of some language, where the regexp wants to match something at the end of the line.
    As an example the shellscript language defines the firstLine detection with:
"firstLine": "^#!.*\\b(bash|zsh|sh|tcsh).*|^#\\s*-\\*-[^*]*mode:\\s*shell-script[^*]*-\\*-",

which wants to match a -*- at the end of the line.
2. Open the file and observe that the language is not detected. Shortening the first line to no more than 100 characters, closing the line and opening it again, makes the language be detected.
E.g. a file name test-file containing the following text:

# -*- mode:shell-script; some-more:1; some-more:1; some-more:1; some-more:1; some-more7890123:12; -*-
#234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
#        ^10       ^20       ^30       ^40       ^50       ^60       ^70       ^80       ^90       ^100

will not be detected as containing shellscript language. Changing the final "12" to "1" brings the length down to 100 and now it will be detected as shellscript.

Presumably this is because of the 100 at textEditorModel.ts.

For Emacs-style mode lines, like the ones shellscript tries to detect, contain file-specific "settings", so they can be quite long. At a minimum, the magic number 100 ought to be documented.

@bpasero bpasero added editor feature-request Request for new features or functionality labels Jul 14, 2019
@rebornix
Copy link
Member

@alexandrudima any reason why we have the limit for the first line?

@alexdima
Copy link
Member

alexdima commented Aug 7, 2019

I don't think we had an actual bug about this, so we have a limit only for the sake that a limit is always a good thing... Maybe we can increase it to some other larger magic number.

@PerMildner
Copy link
Author

Unfortunately, Emacs does not use any fixed limit (in set-auto-mode-1). It uses 3000 as a limit in a related case (looking from the end of a file).

Still, something like 1000 should be more than enough. Even the current 100 would probably suffice if the limit was clearly documented. In my use case I just made the regexp a little less precise.

@alexdima alexdima added this to the August 2019 milestone Aug 9, 2019
@alexdima alexdima modified the milestones: August 2019, September 2019 Aug 27, 2019
@alexdima alexdima modified the milestones: September 2019, October 2019 Sep 30, 2019
@alexdima alexdima added the verification-needed Verification of issue is requested label Oct 28, 2019
@connor4312 connor4312 added verified Verification succeeded and removed verification-needed Verification of issue is requested labels Oct 29, 2019
@vscodebot vscodebot bot locked and limited conversation to collaborators Dec 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

5 participants