-
Notifications
You must be signed in to change notification settings - Fork 842
Fix lexer cache #2158
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
Fix lexer cache #2158
Conversation
|
OMG, this code is... let's call it fragile. Please, don't touch it ever in the future. |
|
Perhaps in the future we'll be able to do away with all of these |
|
|
@dsyme Maybe rename |
|
@vasily-kirichenko this stuff is in FCS / not specific to VS and I think if it was to be renamed |
|
@smoothdeveloper As there are other zero line based editors, then yes, the functions should keep their names, but we should create aliases in FSharp.Editor project with the proposed names. |
|
@dotnet-bot test this please |
|
|
@KevinRansom fixed. |
| while i > 0 && (match sourceTextData.[i] with Some data -> not (data.IsValid(lines.[i])) | None -> true) do | ||
| i <- i - 1 | ||
| i | ||
| // Rescan the lines if necessary and report the information |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
scanStartLine made my head explode or at least the while loop condition did.
I don't know whether this is any more readable though:
let scanStartLine =
let rec scanStart i =
if i > 0 && (Option.isNone (sourceTextData.[i]) || not (sourceTextData.[i].Value.IsValid(lines.[i]))) then scanStart (i - 1)
else i
scanStart startLine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm 100% with you on this. It must be covered by tests, then rewritten in a more functional and safe manner. The number of things this algorithm operates is not as huge to make the code so imperative.
* revert "Use Roslyn line numbers only in lexer cache" dotnet#2090 * fix OutOfRangeException in getCachedSourceLineData * fixed: lexer cache does not work at all * fix finding start line for relexing in getCachedSourceLineData
This fixes #2155
It reverts #2090, then fixes the
OutOfRangeExceptioningetCachedSourceLineData.