Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incremental changes and completion in Cake #1997

Merged
merged 2 commits into from
Nov 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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