diff --git a/presentation-compiler/src/main/dotty/tools/pc/PcCollector.scala b/presentation-compiler/src/main/dotty/tools/pc/PcCollector.scala index 1ebfd405768e..f3fd7c8738d5 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/PcCollector.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/PcCollector.scala @@ -315,7 +315,7 @@ object EndMarker: def getPosition(df: NamedDefTree, pos: SourcePosition, sourceText: String)( implicit ct: Context ): Option[SourcePosition] = - val name = df.name.toString() + val name = df.name.toString().stripSuffix("$") val endMarkerLine = sourceText.slice(df.span.start, df.span.end).split('\n').last val index = endMarkerLine.length() - name.length() diff --git a/presentation-compiler/test/dotty/tools/pc/tests/edit/PcRenameSuite.scala b/presentation-compiler/test/dotty/tools/pc/tests/edit/PcRenameSuite.scala index 3226018f88d4..50806322b09e 100644 --- a/presentation-compiler/test/dotty/tools/pc/tests/edit/PcRenameSuite.scala +++ b/presentation-compiler/test/dotty/tools/pc/tests/edit/PcRenameSuite.scala @@ -534,3 +534,14 @@ class PcRenameSuite extends BasePcRenameSuite: |""".stripMargin, wrap = false ) + + @Test def `local-object-with-end-rename` = + check( + """|def bar = + | object <>: + | def aaa = ??? + | end <> + | 1 + |""".stripMargin, + wrap = false + ) diff --git a/presentation-compiler/test/dotty/tools/pc/tests/tokens/SemanticTokensSuite.scala b/presentation-compiler/test/dotty/tools/pc/tests/tokens/SemanticTokensSuite.scala index fd90a8dfaca0..9f8d82020806 100644 --- a/presentation-compiler/test/dotty/tools/pc/tests/tokens/SemanticTokensSuite.scala +++ b/presentation-compiler/test/dotty/tools/pc/tests/tokens/SemanticTokensSuite.scala @@ -258,7 +258,7 @@ class SemanticTokensSuite extends BaseSemanticTokensSuite: | } = new: | def <>/*method,definition*/ = "4.0" | <>/*variable,readonly*/.<>/*method*/ - |end StructuralTypes + |end <>/*class,definition*/ |""".stripMargin ) @@ -431,4 +431,13 @@ class SemanticTokensSuite extends BaseSemanticTokensSuite: | <>/*method*/[<