Skip to content
This repository was archived by the owner on Jan 3, 2019. It is now read-only.

Commit 96868f8

Browse files
committed
Merge pull request #268 from rneatherway/issue255
Don't offer completions after just a '.'
2 parents e8f8daf + 8e2a158 commit 96868f8

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

FSharp.AutoComplete/Program.fs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,15 +218,14 @@ type internal IntelliSenseAgent() =
218218
/// and current residue.
219219
member x.DoCompletion(opts : RequestOptions, ((line, column) as pos), lineStr, time) : Option<DeclarationSet * String> =
220220
let info = x.GetTypeCheckInfo(opts, time)
221-
Option.bind (fun (info: TypeCheckResults) ->
222-
let longName, residue = Parsing.findLongIdentsAndResidue (column, lineStr)
223-
224-
// Get items & generate output
221+
Option.bind (fun (longName, residue) ->
222+
Option.bind (fun (info: TypeCheckResults) ->
225223
try
226224
Some (info.GetDeclarations(None, pos, lineStr, (longName, residue), fun (_,_) -> false)
227225
|> Async.RunSynchronously, residue)
228226
with :? System.TimeoutException as e ->
229227
None) info
228+
) (Parsing.findLongIdentsAndResidue (column, lineStr))
230229

231230
/// Gets ToolTip for the specified location (and prints it to the output)
232231
member x.GetToolTip(opts, ((line, column) as pos), lineStr, time) : Option<DataTipText> =

FSharp.CompilerBinding/Parser.fs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,4 +324,12 @@ module Parsing =
324324
|> List.rev
325325
|> List.head
326326

327-
(longName, residue)
327+
if String.IsNullOrEmpty residue &&
328+
List.isEmpty longName &&
329+
col >= 0 && col <= lineStr.Length &&
330+
lineStr.[col - 1] = '.'
331+
then
332+
None
333+
else
334+
Some (longName, residue)
335+

monodevelop/MonoDevelop.FSharpBinding/Services/LanguageService.fs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -349,12 +349,15 @@ type internal TypedParseResult(info:TypeCheckResults, untyped : UntypedParseInfo
349349
/// (used to implement dot-completion in 'FSharpTextEditorCompletion.fs')
350350
member x.GetDeclarations(doc:Document, context: CodeCompletion.CodeCompletionContext) =
351351
let line, col, lineStr = getLineInfoFromOffset(doc.Editor.Caret.Offset, doc.Editor.Document)
352-
let longName, residue = Parsing.findLongIdentsAndResidue(col, lineStr)
353352

354-
// Get items & generate output
355-
try Some (info.GetDeclarations(None, (line,col), lineStr, (longName, residue), fun (_,_) -> false)
356-
|> Async.RunSynchronously, residue)
357-
with :? TimeoutException as e -> None
353+
match Parsing.findLongIdentsAndResidue(col, lineStr) with
354+
| None -> None
355+
| Some (longName, residue) ->
356+
Debug.WriteLine (sprintf "GetDeclarations: '%A', '%s'" longName residue)
357+
// Get items & generate output
358+
try Some (info.GetDeclarations(None, (line,col), lineStr, (longName, residue), fun (_,_) -> false)
359+
|> Async.RunSynchronously, residue)
360+
with :? TimeoutException as e -> None
358361

359362
/// Get the tool-tip to be displayed at the specified offset (relatively
360363
/// from the beginning of the current document)

0 commit comments

Comments
 (0)