mirror of
https://github.com/denoland/deno.git
synced 2025-01-21 21:50:00 -05:00
errors: replace .lines with explicit .split newline (#4483)
This commit is contained in:
parent
eeedb416c0
commit
3938071e91
4 changed files with 14 additions and 1 deletions
|
@ -553,7 +553,9 @@ impl SourceMapGetter for TsCompiler {
|
|||
.try_resolve_and_get_source_file(script_name)
|
||||
.and_then(|out| {
|
||||
str::from_utf8(&out.source_code).ok().and_then(|v| {
|
||||
let lines: Vec<&str> = v.lines().collect();
|
||||
// Do NOT use .lines(): it skips the terminating empty line.
|
||||
// (due to internally using .split_terminator() instead of .split())
|
||||
let lines: Vec<&str> = v.split('\n').collect();
|
||||
assert!(lines.len() > line);
|
||||
Some(lines[line].to_string())
|
||||
})
|
||||
|
|
2
cli/tests/error_syntax_empty_trailing_line.mjs
Normal file
2
cli/tests/error_syntax_empty_trailing_line.mjs
Normal file
|
@ -0,0 +1,2 @@
|
|||
// Deliberately using .mjs to avoid triggering prettier
|
||||
setTimeout(() => {}),
|
2
cli/tests/error_syntax_empty_trailing_line.mjs.out
Normal file
2
cli/tests/error_syntax_empty_trailing_line.mjs.out
Normal file
|
@ -0,0 +1,2 @@
|
|||
error: Uncaught SyntaxError: Unexpected end of input
|
||||
► file:///[WILDCARD]cli/tests/error_syntax_empty_trailing_line.mjs:[WILDCARD]
|
|
@ -1302,6 +1302,13 @@ itest!(error_syntax {
|
|||
output: "error_syntax.js.out",
|
||||
});
|
||||
|
||||
itest!(error_syntax_empty_trailing_line {
|
||||
args: "run --reload error_syntax_empty_trailing_line.mjs",
|
||||
check_stderr: true,
|
||||
exit_code: 1,
|
||||
output: "error_syntax_empty_trailing_line.mjs.out",
|
||||
});
|
||||
|
||||
itest!(error_type_definitions {
|
||||
args: "run --reload error_type_definitions.ts",
|
||||
check_stderr: true,
|
||||
|
|
Loading…
Add table
Reference in a new issue