-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix hanging on vfmt-ing large files on windows (#130)
- Loading branch information
Showing
2 changed files
with
56 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
module server | ||
|
||
import lsp | ||
import os | ||
import analyzer | ||
import analyzer.psi | ||
import analyzer.parser | ||
|
||
fn test_large_file() { | ||
test_file := os.real_path(@VMODROOT + '/src/server/general.v') | ||
|
||
src := os.read_file(test_file) or { panic('Cannot read file') } | ||
|
||
mut ls := LanguageServer.new(analyzer.IndexingManager.new()) | ||
ls.setup_toolchain() | ||
ls.setup_vpaths() | ||
|
||
uri := lsp.document_uri_from_path(test_file) | ||
res := parser.parse_code(src) | ||
psi_file := psi.new_psi_file(uri.path(), res.tree, res.source_text) | ||
ls.opened_files[uri] = analyzer.OpenedFile{ | ||
uri: uri | ||
version: 0 | ||
psi_file: psi_file | ||
} | ||
|
||
params := lsp.DocumentFormattingParams{ | ||
text_document: lsp.TextDocumentIdentifier{ | ||
uri: uri | ||
} | ||
} | ||
|
||
text_edit_result := ls.formatting(params) or { panic('Cannot format file') } | ||
assert text_edit_result.len == 1 | ||
} |