提交 1e7037cb 编写于 作者: P Phillip Carter 提交者: Kevin Ransom (msft)

Fix IndexOutOfRangeException in check for providing completion (#4138)

* Fix IndexOutOfRange in check for providing completion:

* Add test
上级 d0785712
......@@ -85,10 +85,9 @@ type internal FSharpCompletionProvider
else
let triggerPosition = caretPosition - 1
let triggerChar = sourceText.[triggerPosition]
let prevChar = sourceText.[triggerPosition - 1]
// do not trigger completion if it's not single dot, i.e. range expression
if not Settings.IntelliSense.ShowAfterCharIsTyped && prevChar = '.' then
if not Settings.IntelliSense.ShowAfterCharIsTyped && triggerPosition > 0 && sourceText.[triggerPosition - 1] = '.' then
false
else
let documentId, filePath, defines = getInfo()
......
......@@ -273,6 +273,18 @@ xVal**y
let triggered = FSharpCompletionProvider.ShouldTriggerCompletionAux(SourceText.From(fileContents), caretPosition, CompletionTriggerKind.Insertion, getInfo)
Assert.IsTrue(triggered, "Completion should trigger after typing an identifier that follows a mathematical operation")
[<Test>]
let ShouldTriggerCompletionAtStartOfFileWithInsertion =
let fileContents = """
l"""
let marker = "l"
let caretPosition = fileContents.IndexOf(marker) + marker.Length
let documentId = DocumentId.CreateNewId(ProjectId.CreateNewId())
let getInfo() = documentId, filePath, []
let triggered = FSharpCompletionProvider.ShouldTriggerCompletionAux(SourceText.From(fileContents), caretPosition, CompletionTriggerKind.Insertion, getInfo)
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.")
[<Test>]
let ShouldDisplayTypeMembers() =
let fileContents = """
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册