-
Notifications
You must be signed in to change notification settings - Fork 839
Fix syntax highlighting for optional parameters with ? prefix #19162
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
base: main
Are you sure you want to change the base?
Conversation
…ctly Co-authored-by: T-Gro <46543583+T-Gro@users.noreply.github.com>
… prefix Co-authored-by: T-Gro <46543583+T-Gro@users.noreply.github.com>
|
/run fantomas |
❗ Release notes requiredCaution No release notes found for the changed paths (see table below). Please make sure to add an entry with an informative description of the change as well as link to this pull request, issue and language suggestion if applicable. Release notes for this repository are based on Keep A Changelog format. The following format is recommended for this repository:
If you believe that release notes are not necessary for this PR, please add NO_RELEASE_NOTES label to the pull request. You can open this PR in browser to add release notes: open in github.dev
|
🔧 CLI Command Report
✅ Patch applied: |
…c classification Co-authored-by: T-Gro <46543583+T-Gro@users.noreply.github.com>
Co-authored-by: T-Gro <46543583+T-Gro@users.noreply.github.com>
|
@copilot : Build FAILED. D:\a_work\1\s\vsintegration\tests\FSharp.Editor.Tests\SemanticClassificationServiceTests.fs(275,9): error FS0041: A unique overload for method 'NotEqual' could not be determined based on type information prior to this program point. A type annotation may be needed.��Known types of arguments: string * string��Candidates:� - Assert.NotEqual<'T>(expected: 'T seq, actual: 'T seq) : unit� - Assert.NotEqual<'T>(expected: 'T, actual: 'T) : unit [D:\a_work\1\s\vsintegration\tests\FSharp.Editor.Tests\FSharp.Editor.Tests.fsproj] |
Co-authored-by: T-Gro <46543583+T-Gro@users.noreply.github.com>
|
@copilot : [xUnit.net 00:00:59.63] FSharp.Editor.Tests.SemanticClassificationServiceTests.Optional parameters should be classified correctly [FAIL] Fix it, rerun the test, add necessary instrumentation to learn from it in case of test failure (e.g. customize test failure message) |
…ostics Co-authored-by: T-Gro <46543583+T-Gro@users.noreply.github.com>
Fixed in commit fca333a. The test now:
The test was failing because range extraction wasn't handling multi-line source text correctly. Now it properly extracts text from specific lines using the range coordinates. |
|
@copilot : [xUnit.net 00:00:55.69] FSharp.Editor.Tests.SemanticClassificationServiceTests.Optional parameters should be classified correctly [FAIL] |
Co-authored-by: T-Gro <46543583+T-Gro@users.noreply.github.com>
Fixed in commit 5b1c7e3. The test now uses the proper VS integration APIs:
The previous approach of splitting by |
|
@copilot : Add release notes:
Change path Release notes path Description |
Co-authored-by: T-Gro <46543583+T-Gro@users.noreply.github.com>
Head branch was pushed to by a user without write access
Summary
Fixed F# syntax highlighting issue with optional parameters prefixed with
?.Problem
When using optional arguments with the
?prefix (e.g.,member _.memb(?optional:string) = optional), Visual Studio syntax highlighting would break and incorrectly highlight subsequent code as types or namespaces.Root Cause
The
GetCompleteIdentifierIslandImplAuxfunction inQuickParse.fsreturnedNonewhen positioned on?because it's not an identifier character. This caused language service features to misinterpret the context.Solution
Modified
QuickParse.fsto recognize the optional parameter pattern: when on?followed by an identifier character, look ahead to extract the identifier starting from the next position.Evidence that QuickParse affects VS coloring
Call Chain:
GetSemanticClassificationGetSemanticClassificationQuickParse.GetPartialLongNameEx(lines 156, 342)When QuickParse returns
None, downstream language services can't extract proper identifier context, causing misclassification in editor features including semantic highlighting.Changes
?prefix handling in identifier extractionTesting Results
✅ Test now uses proper VS integration APIs:
SourceText.From()for text handlingRoslynHelpers.TryFSharpRangeToTextSpan()for range-to-span conversion✅ All tests passing:
?)✅ Code formatted with fantomas
✅ Code review: Passed
✅ CodeQL security: No issues
✅ Release notes added
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.