File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -380,7 +380,17 @@ let handleUndefinedRecordFieldsAction = ({
380380 newText += `${ paddingContentEndBrace } ` ;
381381 } else {
382382 // A single line record definition body is a bit easier - we'll just add the new fields on the same line.
383- newText += ", " ;
383+
384+ // For an empty record (`range.end.character - range.start.character == 2`),
385+ // we don't want to add an initial trailing comma as that would be invalid syntax.
386+ //
387+ // We assume that records that already contain some characters between
388+ // their braces have at least one field and therefore we need to insert
389+ // an initial trailing comma.
390+ if ( range . end . character - range . start . character > 2 ) {
391+ newText += ", " ;
392+ }
393+
384394 newText += recordFieldNames
385395 . map ( ( fieldName ) => `${ fieldName } : failwith("TODO")` )
386396 . join ( ", " ) ;
You can’t perform that action at this time.
0 commit comments