File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments