Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1e7037c

Browse files
cartermpKevinRansom
authored andcommitted
Fix IndexOutOfRangeException in check for providing completion (#4138)
* Fix IndexOutOfRange in check for providing completion:* Add test
1 parentd078571 commit1e7037c

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

‎vsintegration/src/FSharp.Editor/Completion/CompletionProvider.fs‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,9 @@ type internal FSharpCompletionProvider
8585
else
8686
lettriggerPosition= caretPosition-1
8787
lettriggerChar= sourceText.[triggerPosition]
88-
letprevChar= sourceText.[triggerPosition-1]
89-
88+
9089
// do not trigger completion if it's not single dot, i.e. range expression
91-
ifnot Settings.IntelliSense.ShowAfterCharIsTyped&&prevChar='.'then
90+
ifnot Settings.IntelliSense.ShowAfterCharIsTyped&&triggerPosition>0&& sourceText.[triggerPosition-1]='.'then
9291
false
9392
else
9493
letdocumentId,filePath,defines= getInfo()

‎vsintegration/tests/unittests/CompletionProviderTests.fs‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,18 @@ xVal**y
273273
lettriggered= FSharpCompletionProvider.ShouldTriggerCompletionAux(SourceText.From(fileContents), caretPosition, CompletionTriggerKind.Insertion, getInfo)
274274
Assert.IsTrue(triggered,"Completion should trigger after typing an identifier that follows a mathematical operation")
275275

276+
[<Test>]
277+
letShouldTriggerCompletionAtStartOfFileWithInsertion=
278+
letfileContents="""
279+
l"""
280+
281+
letmarker="l"
282+
letcaretPosition= fileContents.IndexOf(marker)+ marker.Length
283+
letdocumentId= DocumentId.CreateNewId(ProjectId.CreateNewId())
284+
letgetInfo()= documentId, filePath,[]
285+
lettriggered= FSharpCompletionProvider.ShouldTriggerCompletionAux(SourceText.From(fileContents), caretPosition, CompletionTriggerKind.Insertion, getInfo)
286+
Assert.IsTrue(triggered,"Completion should trigger after typing an Insertion character at the top of the file, e.g. a function definition in a new script file.")
287+
276288
[<Test>]
277289
letShouldDisplayTypeMembers()=
278290
letfileContents="""

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp