diff --git a/MonoDevelop.MSBuild.Editor/Completion/MSBuildCompletionSource.cs b/MonoDevelop.MSBuild.Editor/Completion/MSBuildCompletionSource.cs index 479a3bfe..12b35320 100644 --- a/MonoDevelop.MSBuild.Editor/Completion/MSBuildCompletionSource.cs +++ b/MonoDevelop.MSBuild.Editor/Completion/MSBuildCompletionSource.cs @@ -56,10 +56,16 @@ protected override MSBuildCompletionContext CreateTriggerContext (IAsyncCompleti protected override Task> GetElementCompletionsAsync (MSBuildCompletionContext context, bool includeBracket, CancellationToken token) { + if (EnableDebugTrace) { + LogTrace ($"Entered GetElementCompletionsAsync"); + } var doc = context.Document; var nodePath = context.NodePath; if (!CompletionHelpers.TryGetElementSyntaxForElementCompletion(nodePath, out MSBuildElementSyntax languageElement, out string elementName)) { + if (EnableDebugTrace) { + LogTrace ($"Exited GetElementCompletionsAsync with no syntax"); + } return TaskCompleted (null); } @@ -80,6 +86,9 @@ protected override Task> GetElementCompletionsAsync (MSBui items.Add (c); } + if (EnableDebugTrace) { + LogTrace ($"Exited GetElementCompletionsAsync with {items.Count} items"); + } return TaskCompleted (items); } diff --git a/MonoDevelop.MSBuild.Tests.Editor/Completion/MSBuildCommitTests.cs b/MonoDevelop.MSBuild.Tests.Editor/Completion/MSBuildCommitTests.cs index 090897c3..feeabfea 100644 --- a/MonoDevelop.MSBuild.Tests.Editor/Completion/MSBuildCommitTests.cs +++ b/MonoDevelop.MSBuild.Tests.Editor/Completion/MSBuildCommitTests.cs @@ -1,11 +1,9 @@ // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; +using System.Threading; using System.Threading.Tasks; -using Microsoft.VisualStudio.Text.Editor.Commanding; - using MonoDevelop.Xml.Editor.Tests.Extensions; using NUnit.Framework; @@ -15,18 +13,26 @@ namespace MonoDevelop.MSBuild.Tests.Editor.Completion [TestFixture] public class MSBuildCommitTests : MSBuildEditorTest { - Task TestTypeCommands (string filename, string before, string typeChars, string after) + async Task TestTypeCommands (string filename, string before, string typeChars, string after) { - return this.TestCommands ( - before, - after, - [ (s) => s.Type (typeChars) ], - filename: filename, - initialize: (tv) => { - tv.Options.SetOptionValue ("BraceCompletion/Enabled", true); - return Task.CompletedTask; - } - ); + //CommandServiceExtensions.EnableDebugTrace = true; + //MSBuildCompletionSource.EnableDebugTrace = true; + //try { + await this.TestCommands ( + before, + after, + EditorAction.Type (typeChars), + filename: filename, + initialize: async (tv) => { + tv.Options.SetOptionValue ("BraceCompletion/Enabled", true); + // ensure we have an initial parse before triggering completion + await Catalog.MSBuildParserProvider.GetParser (tv.TextBuffer).GetOrProcessAsync (tv.TextBuffer.CurrentSnapshot, CancellationToken.None); + } + ); + //} finally { + // CommandServiceExtensions.EnableDebugTrace = false; + // MSBuildCompletionSource.EnableDebugTrace = false; + //} } [Test] diff --git a/MonoDevelop.MSBuild.Tests.Editor/Refactorings/MSBuildEditorTestExtensions.cs b/MonoDevelop.MSBuild.Tests.Editor/Refactorings/MSBuildEditorTestExtensions.cs index 4d5512ce..82095c2e 100644 --- a/MonoDevelop.MSBuild.Tests.Editor/Refactorings/MSBuildEditorTestExtensions.cs +++ b/MonoDevelop.MSBuild.Tests.Editor/Refactorings/MSBuildEditorTestExtensions.cs @@ -224,7 +224,13 @@ public static async Task TestCodeActionContext ( // the refactoring may have left multiple selections sp the user can e.g. type a new name for an extracted property await test.Catalog.JoinableTaskContext.Factory.SwitchToMainThreadAsync (default); var commandService = test.Catalog.CommandServiceFactory.GetService (ctx.TextView); - commandService.Type (typeText); + + foreach(var editorAction in EditorAction.Type (typeText)) { + editorAction (commandService); + // yield to let things catch up + // and so we don't block the UI thread between the commands + await Task.Delay (20); + } Assert.That ( ctx.TextBuffer.CurrentSnapshot.GetText (), diff --git a/MonoDevelop.Xml b/MonoDevelop.Xml index 361e2930..93927f4d 160000 --- a/MonoDevelop.Xml +++ b/MonoDevelop.Xml @@ -1 +1 @@ -Subproject commit 361e2930fe3cbaa8eee787702446ed54e767124c +Subproject commit 93927f4dae3dcc508e7e00550ebb23c94664277d