@@ -55,9 +55,23 @@ type internal FSharpCompletionProvider
5555
5656 let xmlMemberIndexService = serviceProvider.GetService( typeof< IVsXMLMemberIndexService>) :?> IVsXMLMemberIndexService
5757 let documentationBuilder = XmlDocumentation.CreateDocumentationBuilder( xmlMemberIndexService, serviceProvider.DTE)
58-
58+
5959 static let noCommitOnSpaceRules =
60- CompletionItemRules.Default.WithCommitCharacterRule( CharacterSetModificationRule.Create( CharacterSetModificationKind.Remove, ' ' , '=' , ',' , '.' , '<' , '>' , '(' , ')' , '!' , ':' ))
60+ // These are important. They make sure we don't _commit_ autocompletion when people don't expect them to. Some examples:
61+ //
62+ // * type Foo() =
63+ // member val a = 12 with get, <<---- Don't commit autocomplete!
64+ //
65+ // * type MyRecord = { name: <<---- Don't commit autocomplete!
66+ //
67+ // * type My< <<---- Don't commit autocomplete!
68+ //
69+ // * let myClassInstance = MyClass(Date= <<---- Don't commit autocomplete!
70+ //
71+ // * let xs = [1..10] <<---- Don't commit autocomplete! (same for arrays)
72+ let noCommitChars = [| ' ' ; '=' ; ',' ; '.' ; '<' ; '>' ; '(' ; ')' ; '!' ; ':' ; '[' ; ']' ; '|' |]. ToImmutableArray()
73+
74+ CompletionItemRules.Default.WithCommitCharacterRule( CharacterSetModificationRule.Create( CharacterSetModificationKind.Remove, noCommitChars))
6175
6276 static let getRules () = if Settings.IntelliSense.ShowAfterCharIsTyped then noCommitOnSpaceRules else CompletionItemRules.Default
6377
@@ -100,14 +114,14 @@ type internal FSharpCompletionProvider
100114 let caretLine = textLines.GetLineFromPosition( caretPosition)
101115 let fcsCaretLineNumber = Line.fromZ caretLinePos.Line // Roslyn line numbers are zero-based, FSharp.Compiler.Service line numbers are 1-based
102116 let caretLineColumn = caretLinePos.Character
103- let qualifyingNames , partialName = QuickParse.GetPartialLongNameEx( caretLine.ToString(), caretLineColumn - 1 )
117+ let partialName = QuickParse.GetPartialLongNameEx( caretLine.ToString(), caretLineColumn - 1 )
104118
105119 let getAllSymbols () =
106- getAllSymbols() |> List.filter ( fun entity -> entity.FullName.Contains " ." && not ( PrettyNaming.IsOperatorName entity.Symbol.DisplayName))
120+ getAllSymbols()
121+ |> List.filter ( fun entity -> entity.FullName.Contains " ." && not ( PrettyNaming.IsOperatorName entity.Symbol.DisplayName))
107122
108- let! declarations =
109- checkFileResults.GetDeclarationListInfo( Some( parseResults), fcsCaretLineNumber, caretLineColumn, caretLine.ToString(), qualifyingNames, partialName, getAllSymbols, userOpName= userOpName) |> liftAsync
110-
123+ let! declarations = checkFileResults.GetDeclarationListInfo( Some( parseResults), fcsCaretLineNumber, caretLine.ToString(),
124+ partialName, getAllSymbols, userOpName= userOpName) |> liftAsync
111125 let results = List< Completion.CompletionItem>()
112126
113127 let getKindPriority = function
@@ -186,7 +200,7 @@ type internal FSharpCompletionProvider
186200 declarationItemsCache.Add( completionItem.DisplayText, declItem)
187201 results.Add( completionItem))
188202
189- if results.Count > 0 && not declarations.IsForType && not declarations.IsError && List.isEmpty qualifyingNames then
203+ if results.Count > 0 && not declarations.IsForType && not declarations.IsError && List.isEmpty partialName.QualifyingIdents then
190204 let lineStr = textLines.[ caretLinePos.Line]. ToString()
191205 match UntypedParseImpl.TryGetCompletionContext( Pos.fromZ caretLinePos.Line caretLinePos.Character, Some parseResults, lineStr) with
192206 | None -> results.AddRange( keywordCompletionItems)
0 commit comments