From 23ab5ea90adc95873a6603ece17ef1dcd668ad16 Mon Sep 17 00:00:00 2001 From: Vishwanath Martur <64204611+vishwamartur@users.noreply.github.com> Date: Fri, 17 Jan 2025 05:37:58 +0530 Subject: [PATCH] Fix multiline completion to start automatically after hitting Tab Related to #30 Add automatic triggering of the next portion of multiline completion after hitting Tab. * Modify `MultilineGreyText/RefactCompletionCommandHandler.cs` to call `GetLSPCompletions` after `CompleteText` in the `Exec` method. * Modify `MultilineGreyText/MultilineGreyTextTagger.cs` to add a `RequestNextPortion` method and call it after `CompleteText` in the `CompleteText` method. --- MultilineGreyText/MultilineGreyTextTagger.cs | 13 ++++++++++++- MultilineGreyText/RefactCompletionCommandHandler.cs | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/MultilineGreyText/MultilineGreyTextTagger.cs b/MultilineGreyText/MultilineGreyTextTagger.cs index fadb70f..34efdbd 100644 --- a/MultilineGreyText/MultilineGreyTextTagger.cs +++ b/MultilineGreyText/MultilineGreyTextTagger.cs @@ -446,6 +446,7 @@ public bool CompleteText(){ int diff = untrimLine.Length - untrimLine.TrimStart().Length; string whitespace = String.IsNullOrWhiteSpace(untrimLine) ? "" : untrimLine.Substring(0, diff); ReplaceText(whitespace + suggestion.Item1, currentTextLineN); + RequestNextPortion(); // Pa8f8 return true; } @@ -511,5 +512,15 @@ void MarkDirty(){ this.TagsChanged(this, new SnapshotSpanEventArgs(span)); } } + + // Request the next portion of multiline completion + public void RequestNextPortion(){ + var key = typeof(RefactCompletionCommandHandler); + var props = view.TextBuffer.Properties; + if (props.ContainsProperty(key)){ + var handler = props.GetProperty(key); + handler.GetLSPCompletions(); + } + } } -} \ No newline at end of file +} diff --git a/MultilineGreyText/RefactCompletionCommandHandler.cs b/MultilineGreyText/RefactCompletionCommandHandler.cs index e066990..77ddd7d 100644 --- a/MultilineGreyText/RefactCompletionCommandHandler.cs +++ b/MultilineGreyText/RefactCompletionCommandHandler.cs @@ -219,6 +219,7 @@ public int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pv if (tagger != null){ if (tagger.IsSuggestionActive() && tagger.CompleteText()){ ClearCompletionSessions(); + GetLSPCompletions(); // P5b41 return VSConstants.S_OK; }else{ tagger.ClearSuggestion();