Skip to content
This repository was archived by the owner on Oct 16, 2020. It is now read-only.

Commit 3f0a433

Browse files
cancel XAML completion in attribute values, if '{' is pressed and we are in an empty attribute value
1 parent e61e0fa commit 3f0a433

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlCodeCompletionBinding.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,9 @@ bool DoMarkupExtensionCompletion(XamlCompletionContext context)
397397
if (context.Description == XamlContextDescription.InMarkupExtension && context.AttributeValue != null && !context.AttributeValue.IsString) {
398398
if (!XamlBindingOptions.UseExtensionCompletion)
399399
return false;
400-
XamlCompletionItemList completionList = generator.CreateMarkupExtensionCompletion(context) as XamlCompletionItemList;
400+
var completionList = generator.CreateMarkupExtensionCompletion(context) as XamlCompletionItemList;
401+
if (completionList == null)
402+
return false;
401403
string word = context.Editor.GetWordBeforeCaretExtended();
402404
if (context.PressedKey != '.' && context.PressedKey != '=' && !word.EndsWith(".", StringComparison.Ordinal) && completionList.PreselectionLength == 0)
403405
completionList.PreselectionLength = word.Length;

src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlCompletionItemList.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,13 @@ public override CompletionItemListKeyResult ProcessInput(char key)
4141
if (key == ':' || key == '/')
4242
return CompletionItemListKeyResult.NormalKey;
4343

44-
if (key == '.' && (context.InAttributeValueOrMarkupExtension && context.Attribute.Name.StartsWith("xmlns")))
44+
if (key == '.' && (context.InAttributeValueOrMarkupExtension && context.Attribute.Name.StartsWith("xmlns", StringComparison.Ordinal)))
4545
return CompletionItemListKeyResult.NormalKey;
4646

47+
// cancel completion if user might want to start a markup extension and value is still empty
48+
if (key == '{' && (context.InAttributeValueOrMarkupExtension && string.IsNullOrEmpty(context.RawAttributeValue)))
49+
return CompletionItemListKeyResult.Cancel;
50+
4751
return base.ProcessInput(key);
4852
}
4953

0 commit comments

Comments
 (0)