@@ -128,16 +128,13 @@ final class PcInlineValueProvider(
128128 end for
129129 end defAndRefs
130130
131- private def stripIndentPrefix (rhs : String , refIndent : String , defIndent : String ): String =
131+ private def stripIndentPrefix (rhs : String , refIndent : String , defIndent : String , hasNextLineAfterEqualsSign : Boolean ): String =
132132 val rhsLines = rhs.split(" \n " ).nn.toList
133133 rhsLines match
134134 case h :: Nil => rhs
135135 case h :: t =>
136- val noPrefixH = h.nn.stripPrefix(refIndent)
137- if noPrefixH.startsWith(" {" ) then
138- noPrefixH ++ t.map(refIndent ++ _.nn.stripPrefix(defIndent)).mkString(" \n " ," \n " , " " )
139- else
140- ((" " ++ h.nn) :: t).map(refIndent ++ _.nn.stripPrefix(defIndent)).mkString(" \n " , " \n " , " " )
136+ val header = if ! hasNextLineAfterEqualsSign then h else s " \n $refIndent $h"
137+ header.nn ++ t.map(refIndent ++ _.nn.stripPrefix(defIndent)).mkString(" \n " , " \n " , " " )
141138 case Nil => rhs
142139
143140 private def definitionRequiresBrackets (tree : Tree )(using Context ): Boolean =
@@ -236,7 +233,7 @@ final class PcInlineValueProvider(
236233 var idx = source.startOfLine(offset)
237234 val pad = new StringBuilder
238235 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))
240237 idx += 1
241238 }
242239 pad.result()
@@ -262,14 +259,17 @@ final class PcInlineValueProvider(
262259 case _ => false
263260 }
264261 .map(_.fullNameBackticked)
262+ val hasNextLineAfterEqualsSign =
263+ definition.tree.sourcePos.startLine != definition.tree.rhs.sourcePos.startLine
265264 if conflictingSymbols.isEmpty then
266265 Right (
267266 Reference (
268267 occurrence.pos.toLsp,
269268 stripIndentPrefix(
270269 extendWithSurroundingParens(definition.tree.rhs.sourcePos),
271270 occurrence.tree.startPos.startColumnIndentPadding,
272- definition.tree.startPos.startColumnIndentPadding
271+ definition.tree.startPos.startColumnIndentPadding,
272+ hasNextLineAfterEqualsSign
273273 ),
274274 occurrence.parent.map(p =>
275275 RangeOffset (p.sourcePos.start, p.sourcePos.end)
0 commit comments