From b8fce0c5572cd38c1590dfbe5e5fecd32c542c8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Kr=C3=BCger?= Date: Mon, 24 Sep 2012 12:18:24 +0200 Subject: [PATCH] [CodeCompletion] Fixed ctrl+space behavior (it's now more intrusive - but it should be it, the user requests it). --- .../Completion/CSharpCompletionEngine.cs | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngine.cs b/ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngine.cs index 8f92a92a27..027d7638c6 100644 --- a/ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngine.cs +++ b/ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngine.cs @@ -671,18 +671,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion return controlSpace ? HandleAccessorContext() ?? DefaultControlSpaceItems(identifierStart) : null; } - char prevCh = offset > 2 ? document.GetCharAt(offset - 2) : ';'; - char nextCh = offset < document.TextLength ? document.GetCharAt(offset) : ' '; - const string allowedChars = ";,.[](){}+-*/%^?:&|~!<>="; - if (!Char.IsWhiteSpace(nextCh) && allowedChars.IndexOf(nextCh) < 0) { - return null; - } - if (!(Char.IsWhiteSpace(prevCh) || allowedChars.IndexOf(prevCh) >= 0)) { - if (controlSpace && identifierStart != null && identifierStart.Node is IdentifierExpression) - return DefaultControlSpaceItems(identifierStart); - return null; - } // Do not pop up completion on identifier identifier (should be handled by keyword completion). tokenIndex = offset - 1; token = GetPreviousToken(ref tokenIndex, false); @@ -694,6 +683,16 @@ namespace ICSharpCode.NRefactory.CSharp.Completion if (keywordresult != null) { return keywordresult; } + + char prevCh = offset > 2 ? document.GetCharAt(offset - 2) : ';'; + char nextCh = offset < document.TextLength ? document.GetCharAt(offset) : ' '; + const string allowedChars = ";,.[](){}+-*/%^?:&|~!<>="; + + if ((!Char.IsWhiteSpace(nextCh) && allowedChars.IndexOf(nextCh) < 0) || !(Char.IsWhiteSpace(prevCh) || allowedChars.IndexOf(prevCh) >= 0)) { + if (controlSpace) + return DefaultControlSpaceItems(identifierStart); + return null; + } int prevTokenIndex = tokenIndex; var prevToken2 = GetPreviousToken(ref prevTokenIndex, false);