@@ -128,16 +128,13 @@ final class PcInlineValueProvider(
128
128
end for
129
129
end defAndRefs
130
130
131
- private def stripIndentPrefix (rhs : String , refIndent : String , defIndent : String ): String =
131
+ private def stripIndentPrefix (rhs : String , refIndent : String , defIndent : String , hasNextLineAfterEqualsSign : Boolean ): String =
132
132
val rhsLines = rhs.split(" \n " ).toList
133
133
rhsLines match
134
134
case h :: Nil => rhs
135
135
case h :: t =>
136
- val noPrefixH = h.stripPrefix(refIndent)
137
- if noPrefixH.startsWith(" {" ) then
138
- noPrefixH ++ t.map(refIndent ++ _.stripPrefix(defIndent)).mkString(" \n " ," \n " , " " )
139
- else
140
- ((" " ++ h) :: t).map(refIndent ++ _.stripPrefix(defIndent)).mkString(" \n " , " \n " , " " )
136
+ val header = if ! hasNextLineAfterEqualsSign then h else " \n " ++ refIndent ++ " " ++ h
137
+ header ++ t.map(refIndent ++ _.stripPrefix(defIndent)).mkString(" \n " , " \n " , " " )
141
138
case Nil => rhs
142
139
143
140
private def definitionRequiresBrackets (tree : Tree )(using Context ): Boolean =
@@ -236,7 +233,7 @@ final class PcInlineValueProvider(
236
233
var idx = source.startOfLine(offset)
237
234
val pad = new StringBuilder
238
235
while (idx != offset && idx < source.content().length && source.content()(idx).isWhitespace) {
239
- pad.append(if (idx < source.content().length && source.content()( idx) == ' \t ' ) ' \t ' else ' ' )
236
+ pad.append(source.content()( idx))
240
237
idx += 1
241
238
}
242
239
pad.result()
@@ -262,14 +259,17 @@ final class PcInlineValueProvider(
262
259
case _ => false
263
260
}
264
261
.map(_.fullNameBackticked)
262
+ val hasNextLineAfterEqualsSign =
263
+ definition.tree.sourcePos.startLine != definition.tree.rhs.sourcePos.startLine
265
264
if conflictingSymbols.isEmpty then
266
265
Right (
267
266
Reference (
268
267
occurrence.pos.toLsp,
269
268
stripIndentPrefix(
270
269
extendWithSurroundingParens(definition.tree.rhs.sourcePos),
271
270
occurrence.tree.startPos.startColumnIndentPadding,
272
- definition.tree.startPos.startColumnIndentPadding
271
+ definition.tree.startPos.startColumnIndentPadding,
272
+ hasNextLineAfterEqualsSign
273
273
),
274
274
occurrence.parent.map(p =>
275
275
RangeOffset (p.sourcePos.start, p.sourcePos.end)
0 commit comments