You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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:
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.
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.
The text was updated successfully, but these errors were encountered:
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.
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.
Steps to Reproduce:
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 thefirstLine
detection with: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: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 asshellscript
.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.The text was updated successfully, but these errors were encountered: