Skip to content

Commit

Permalink
improvement: trim hover body
Browse files Browse the repository at this point in the history
  • Loading branch information
kasiaMarek committed Sep 29, 2023
1 parent 95e42a9 commit b4072c7
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package scala.meta.internal.pc

object HoverMarkup {

private val MaxHoverBodyLength = 50000

/**
* Render the textDocument/hover result into markdown.
*
Expand Down Expand Up @@ -42,15 +44,19 @@ object HoverMarkup {
markdown.toString()
}

private def trimBody(body: String) =
if (body.length() <= MaxHoverBodyLength) body
else body.take(MaxHoverBodyLength) + "..."

def apply(body: String): String = {
s"""|```scala
|$body
|${trimBody(body)}
|```""".stripMargin
}

def javaHoverMarkup(body: String): String = {
s"""|```java
|$body
|${trimBody(body)}
|```""".stripMargin
}

Expand Down

0 comments on commit b4072c7

Please sign in to comment.