Skip to content

Commit

Permalink
chore: Take into account charset
Browse files Browse the repository at this point in the history
  • Loading branch information
tgodzik committed Oct 16, 2023
1 parent b91dfda commit 3cef32b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package scala.meta.internal.metals

import java.nio.charset.Charset
import java.util.Collections
import java.util.concurrent.atomic.AtomicReference

Expand Down Expand Up @@ -32,6 +33,7 @@ import org.eclipse.{lsp4j => l}
final class InteractiveSemanticdbs(
workspace: AbsolutePath,
buildTargets: BuildTargets,
charset: Charset,
client: MetalsLanguageClient,
tables: Tables,
statusBar: StatusBar,
Expand Down Expand Up @@ -86,7 +88,7 @@ final class InteractiveSemanticdbs(
source,
(path, existingDoc) => {
unsavedContents.orElse(buffers.get(source).orElse {
if (source.exists) Some(source.readText)
if (source.exists) Some(source.readText(charset))
else None
}) match {
case None => null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ class MetalsLspService(
new InteractiveSemanticdbs(
folder,
buildTargets,
charset,
languageClient,
tables,
statusBar,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package scala.meta.internal.mtags

import java.net.URI
import java.nio.charset.Charset
import java.nio.charset.StandardCharsets
import java.nio.file.Files
import java.nio.file.Path
Expand Down Expand Up @@ -285,8 +286,12 @@ trait ScalametaCommonEnrichments extends CommonMtagsEnrichments {
}
}

def readText(charset: Charset): String = {
FileIO.slurp(path, charset)
}

def readText: String = {
FileIO.slurp(path, StandardCharsets.UTF_8)
readText(StandardCharsets.UTF_8)
}

def readTextOpt: Option[String] = {
Expand Down

0 comments on commit 3cef32b

Please sign in to comment.