-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Paragraph separator character causes TS Server to get into bad state #38078
Comments
In JavaScript, Paragraph Separator is a line terminator; however, in the edits described above, VS Code says that edits are occur on line 2. From TypeScript's perspective, line 2 occurs immediately after the Paragraph Separator. Ultimately, editors need to account for each language's newline settings if they intent to use line/offset encodings for commands, so I don't think we can fix this on the TypeScript side. |
See also:
|
Here's the edit we send to TSServer when deleting the space after the
The indexes one based so they look correct to me. @RyanCavanaugh @DanielRosenwasser Does this also match what you see? |
Yeah, that's what I'm seeing as well, but if I understand correctly the edit needs to happen at line 3 because the paragraph separator is a line terminator. |
VS Code does not consider the character a line break. Looks like VS does though @alexdima should be able to say if this is intentional or not. If you have this character in your code and it's not inside a string though, it's probably a bug |
This issue has been marked as 'External' and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
Currently, VS Code considers the following characters/sequences to be line terminators: I feel that this is a difficult topic to get wide agreement on, since we need to work with multiple programming languages, each one with its own definition of what a line terminator is. So, if a compiler creates a diagnostic at line 100, it appears that line number is defined according to the programming language's own specification. From my reading of https://www.unicode.org/reports/tr14/tr14-32.html , Unicode defines a mandatory line break after the following:
Here I'm looking at the most popular languages used in VS Code for which I could find a specification or where the decision is not pushed out to specific implementations (looking at you, C++). It looks like the JS spec Table 33 defines the following as line terminators. I suppose TS uses the same: Interestingly, the C# spec A.1.1 Line terminators defines the same line terminators: HTML however defines newlines as just Python also defines just PHP also defines just Java defines YAML section 3.1.4 Line Breaks uses the following: To sum up:
I am not sure what would be best, since it would be very difficult to make VS Code end-of-line sequence dependent on the file's language and changing things now might break language extensions which follow our definition. @dbaeumer Is the end-of-line sequence something that is specified in the Language Server Protocol? |
Actually, a straight forward way to tackle this would be for us to prompt users and ask for permission to "fix" their files. Most likely, |
The LSP support |
From microsoft/vscode#95685
TypeScript Version: 3.9.0-dev.20200420
Search Terms:
Code
For the JS
Note there is an invisible paragraph separator character after the opening
[
=
on the second line.Bug:
TS starts reporting bogus errors:
It looks the paragraph character messes up the parsing and causes the error line numbers to be off by one
The text was updated successfully, but these errors were encountered: