Skip to content

Commit

Permalink
Merge pull request #1997 from mholo65/feature/fix-cake
Browse files Browse the repository at this point in the history
Fix incremental changes and completion in Cake
  • Loading branch information
david-driscoll authored Nov 2, 2020
2 parents edc1364 + 375aa0b commit f238e58
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/OmniSharp.Cake/Extensions/ResponseExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,14 +200,17 @@ public static async Task<CompletionResponse> TranslateAsync(this CompletionRespo
{
foreach (var item in response.Items)
{
if (item.AdditionalTextEdits is null)
if (item.TextEdit is null)
{
continue;
}

var (_, textEdit) = await item.TextEdit.TranslateAsync(workspace, request.FileName);
item.TextEdit = textEdit;

List<LinePositionSpanTextChange> additionalTextEdits = null;

foreach (var additionalTextEdit in item.AdditionalTextEdits)
foreach (var additionalTextEdit in item.AdditionalTextEdits ?? Enumerable.Empty<LinePositionSpanTextChange>())
{
var (_, change) = await additionalTextEdit.TranslateAsync(workspace, request.FileName);

Expand Down
8 changes: 8 additions & 0 deletions src/OmniSharp.Cake/Services/CakeScriptService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ public CakeScript Generate(FileChange fileChange)
throw new InvalidOperationException("Service not initialized.");
}

if (!fileChange.FromDisk && fileChange.Buffer is null && fileChange.LineChanges.Count == 0)
{
return new CakeScript
{
Source = null
};
}

var cakeScript = _generationService.Generate(fileChange);

// Set line processor for generated aliases. TODO: Move to Cake.Bakery
Expand Down

0 comments on commit f238e58

Please sign in to comment.