Skip to content

Commit 9ce900e

Browse files
nordlowWebFreak001
authored andcommitted
Add parameter skipTextValidation to getOrFromFilesystem to bypass UTF-8 validation for systems that already does this elsewhere
1 parent 6fc7b27 commit 9ce900e

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lsp/source/served/lsp/textdocumentmanager.d

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -781,16 +781,18 @@ struct TextDocumentManager
781781
/// URIs. (e.g. normalized URIs)
782782
/// inserted = if specified, gets set to true if the file was read from
783783
/// filesystem and false if it was already present.
784+
/// skipTextValidation = if specified, skips UTF-8 validation of document
785+
/// text read from filesystem.
784786
///
785787
/// Returns: the created document
786788
///
787789
/// Throws: FileException in case the file doesn't exist or other file
788790
/// system errors. In this case no new document should have been
789791
/// inserted yet.
790-
ref Document getOrFromFilesystem(DocumentUri uri, out bool inserted)
792+
ref Document getOrFromFilesystem(DocumentUri uri, out bool inserted, bool skipTextValidation = false)
791793
{
792794
import served.lsp.uri : uriToFile;
793-
import std.file : readText;
795+
import std.file : read, readText;
794796

795797
auto docP = uri in documentStore;
796798
inserted = docP is null;
@@ -800,7 +802,9 @@ struct TextDocumentManager
800802
typeof(return) doc;
801803
doc.uri = uri;
802804
doc.version_ = -1;
803-
doc.setContent(uri.uriToFile.readText());
805+
const path = uri.uriToFile;
806+
const text = skipTextValidation ? (cast(string)path.read) : path.readText;
807+
doc.setContent(text);
804808

805809
return documentStore[uri] = doc;
806810
}

0 commit comments

Comments
 (0)