Skip to content
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
9 changes: 9 additions & 0 deletions src/Eto.DevExtension.LanguageServer/CompletionService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ static CompletionService()
// a comma between json properties is too early; the space or quote after it opens completion instead
if (triggerCharacter == "," && format == CompletionFormat.Json && !context.Quoted)
return results;
// a quote that ends a value has nothing to complete until the next space
if ((triggerCharacter == "\"" || triggerCharacter == "'") && !context.Quoted)
return results;

var range = ToRange(text, context.Start, context.End);
var eventRequest = EventCompletion.Read(context);
Expand All @@ -53,6 +56,11 @@ static CompletionService()
return results;
}

// typing the closing quote accepts a value, and the editor then steps over the one already there
var quote = context.Start > 0 ? text[context.Start - 1] : '\0';
var commitCharacters = context.Quoted && context.Info.Mode == CompletionMode.Value && context.Binding == null && context.Markup == null && (quote == '"' || quote == '\'')
? new List<string> { quote.ToString() }
: null;
foreach (var item in DocumentCompletion.GetItems(context))
{
var snippet = snippets && item.ValueText != null;
Expand All @@ -72,6 +80,7 @@ static CompletionService()
? new Command { Title = "Suggest", Name = triggerSuggestCommand }
: null,
// lets a client without snippets, such as Visual Studio, add the value itself
CommitCharacters = commitCharacters,
Data = item.ValueText == null ? null : new CompletionData { ValueText = item.ValueText, ValueReplaces = item.ValueReplaces },
AdditionalTextEdits = item.NamespaceEdit == null ? null : new List<TextEdit>
{
Expand Down
1 change: 1 addition & 0 deletions src/Eto.DevExtension.LanguageServer/Lsp/Protocol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public class CompletionItem
public TextEdit TextEdit { get; set; }
public List<TextEdit> AdditionalTextEdits { get; set; }
public int? InsertTextFormat { get; set; }
public List<string> CommitCharacters { get; set; }
public Command Command { get; set; }
public CompletionData Data { get; set; }
}
Expand Down
8 changes: 8 additions & 0 deletions src/Eto.DevExtension.VSCode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@
"onLanguage:jeto"
],
"contributes": {
"configurationDefaults": {
"[xeto]": {
"editor.autoClosingOvertype": "always"
},
"[jeto]": {
"editor.autoClosingOvertype": "always"
}
},
"keybindings": [
{
"key": "=",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ public CompletionStartData InitializeCompletion(CompletionTrigger trigger, Snaps
if (context == null)
return CompletionStartData.DoesNotParticipateInCompletion;

// a comma between properties is too early; the space or quote after it opens completion instead
if (trigger.Reason == CompletionTriggerReason.Insertion && trigger.Character == ',' && !context.Quoted)
// a comma between properties, or a quote ending a string, is too early; the space or quote after it opens completion instead
if (trigger.Reason == CompletionTriggerReason.Insertion && (trigger.Character == ',' || trigger.Character == '"' || trigger.Character == '\'') && !context.Quoted)
return CompletionStartData.DoesNotParticipateInCompletion;

var span = new SnapshotSpan(triggerLocation.Snapshot, context.Start, context.End - context.Start);
Expand Down
Loading