Skip to content

Commit ffdaa6e

Browse files
committed
rollback the behavior to pre-dotnet#18899
1 parent 04d0c5b commit ffdaa6e

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

src/Compiler/Service/ServiceParseTreeWalk.fs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ module SyntaxTraversal =
400400
let traverseSynType = traverseSynType path
401401
let traversePat = traversePat path
402402

403-
let diveIntoRecordLikeExpr path (exprRange: range) (hasFields: bool) (copyOpt: (SynExpr * BlockSeparator option) option) =
403+
let diveIntoRecordLikeExpr path (copyOpt: (SynExpr * BlockSeparator option) option) =
404404
[
405405
match copyOpt with
406406
| Some(expr, blockSep) ->
@@ -418,15 +418,21 @@ module SyntaxTraversal =
418418
else
419419
None)
420420
| None ->
421-
// If there is a copy-with but no explicit separator and no fields yet,
422-
// still offer field completions once the caret is after the copy expr.
423-
if not hasFields then
421+
// FIXME: handle caret-after-WITH when no separator token
422+
match expr with
423+
| SynExpr.Ident id ->
424+
let idEnd = id.idRange.End
425+
let withStartPos = mkPos idEnd.Line idEnd.Column
426+
let withEndPos = mkPos idEnd.Line (idEnd.Column + 4)
427+
let withRange = withStartEnd withStartPos withEndPos id.idRange
428+
424429
yield
425-
dive () exprRange (fun () ->
426-
if posGeq pos expr.Range.End then
430+
dive () withRange (fun () ->
431+
if posGeq pos withEndPos then
427432
visitor.VisitRecordField(path, Some expr, None)
428433
else
429434
None)
435+
| _ -> ()
430436
| None -> ()
431437
]
432438

@@ -474,7 +480,7 @@ module SyntaxTraversal =
474480

475481
| SynExpr.AnonRecd(copyInfo = copyOpt; recordFields = fields) ->
476482
[
477-
yield! diveIntoRecordLikeExpr path expr.Range (not (List.isEmpty fields)) copyOpt
483+
yield! diveIntoRecordLikeExpr path copyOpt
478484

479485
for field, _, x in fields do
480486
yield dive () field.Range (fun () -> visitor.VisitRecordField(path, copyOpt |> Option.map fst, Some field))
@@ -519,7 +525,7 @@ module SyntaxTraversal =
519525
| None -> ()
520526
| _ -> ()
521527

522-
yield! diveIntoRecordLikeExpr path expr.Range (not (List.isEmpty fields)) copyOpt
528+
yield! diveIntoRecordLikeExpr path copyOpt
523529

524530
let copyOpt = Option.map fst copyOpt
525531

0 commit comments

Comments
 (0)