diff --git a/metals/src/main/scala/scala/meta/internal/metals/DefinitionProvider.scala b/metals/src/main/scala/scala/meta/internal/metals/DefinitionProvider.scala index e8c01162996..4d28927c544 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/DefinitionProvider.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/DefinitionProvider.scala @@ -81,7 +81,10 @@ final class DefinitionProvider( new ScaladocDefinitionProvider(buffers, trees, destinationProvider) private def isAmmonnite(path: AbsolutePath): Boolean = - path.isAmmoniteScript && buildTargets.inverseSources(path).flatMap(buildTargets.targetData).exists(_.isAmmonite) + path.isAmmoniteScript && buildTargets + .inverseSources(path) + .flatMap(buildTargets.targetData) + .exists(_.isAmmonite) def definition( path: AbsolutePath, @@ -90,17 +93,24 @@ final class DefinitionProvider( ): Future[DefinitionResult] = for { fromCompiler <- - if (path.isScalaFilename && !isAmmonnite(path)) compilers().definition(params, token) + if (path.isScalaFilename && !isAmmonnite(path)) + compilers().definition(params, token) else Future.successful(DefinitionResult.empty) } yield { if (!fromCompiler.isEmpty) { - val pathToDef = fromCompiler.locations.asScala.head.getUri.toAbsolutePath - fromCompiler.copy(semanticdb = semanticdbs().textDocument(pathToDef).documentIncludingStale) + val pathToDef = + fromCompiler.locations.asScala.head.getUri.toAbsolutePath + fromCompiler.copy(semanticdb = + semanticdbs().textDocument(pathToDef).documentIncludingStale + ) } else { val reportBuilder = new DefinitionProviderReportBuilder(path, params, fromCompiler) val fromSemanticDB = - semanticdbs().textDocument(path).documentIncludingStale.map(definitionFromSnapshot(path, params, _)) + semanticdbs() + .textDocument(path) + .documentIncludingStale + .map(definitionFromSnapshot(path, params, _)) fromSemanticDB.foreach(reportBuilder.withSemanticDBResult(_)) val result = fromSemanticDB match { case Some(definition) diff --git a/metals/src/main/scala/scala/meta/internal/rename/RenameProvider.scala b/metals/src/main/scala/scala/meta/internal/rename/RenameProvider.scala index 8302eac5445..ac85c165d4c 100644 --- a/metals/src/main/scala/scala/meta/internal/rename/RenameProvider.scala +++ b/metals/src/main/scala/scala/meta/internal/rename/RenameProvider.scala @@ -336,10 +336,13 @@ final class RenameProvider( } private def findDefinitionRage(location: Location): Location = { - val adjustedPosition = for { + val adjustedPosition = for { source <- location.getUri().toAbsolutePathSafe tree <- trees.get(source) - pos <- location.getRange().getStart().toMeta(Input.VirtualFile(source.toString(), tree.text)) + pos <- location + .getRange() + .getStart() + .toMeta(Input.VirtualFile(source.toString(), tree.text)) token <- tree.tokens.collectFirst { case token: Ident if token.pos.contains(pos) => token }