From 12b954241427af470bb2ecb5186bd28e5f635c0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Kr=C3=BCger?= Date: Mon, 30 Jan 2012 11:16:37 +0100 Subject: [PATCH] Fixed other LINQ case. --- .../Completion/CSharpCompletionEngine.cs | 2 ++ .../CodeCompletionCSharp3Tests.cs | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngine.cs b/ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngine.cs index a24ef83d29..ab03a26f85 100644 --- a/ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngine.cs +++ b/ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngine.cs @@ -408,6 +408,8 @@ namespace ICSharpCode.NRefactory.CSharp.Completion if (IsInsideCommentOrString ()) return null; if (IsInLinqContext (offset)) { + if (!controlSpace && !(char.IsLetter (completionChar) || completionChar == '_')) + return null; tokenIndex = offset; token = GetPreviousToken (ref tokenIndex, false); // token last typed if (!char.IsWhiteSpace (completionChar) && !linqKeywords.Contains (token)) diff --git a/ICSharpCode.NRefactory.Tests/CSharp/CodeCompletion/CodeCompletionCSharp3Tests.cs b/ICSharpCode.NRefactory.Tests/CSharp/CodeCompletion/CodeCompletionCSharp3Tests.cs index bdf8ab0d73..3492e7b6ea 100644 --- a/ICSharpCode.NRefactory.Tests/CSharp/CodeCompletion/CodeCompletionCSharp3Tests.cs +++ b/ICSharpCode.NRefactory.Tests/CSharp/CodeCompletion/CodeCompletionCSharp3Tests.cs @@ -447,6 +447,25 @@ class A } } +"); + Assert.IsTrue(provider == null || provider.Count == 0); // <--- here 0 item in the completion list + } + + [Test()] + public void TestLinqExpressionContext () + { + var provider = CodeCompletionBugTests.CreateProvider( +@" +using System.Collections.Generic; +using System.Linq; +class A +{ + public static void Main (string[] args) + { + $from a in args where a !$ + } +} + "); Assert.IsTrue(provider == null || provider.Count == 0); // <--- here 0 item in the completion list }