From 89ffb20c6b0ae46b0b86ad46ddd68f2cdc0ecc72 Mon Sep 17 00:00:00 2001 From: Priyanshu Dangare Date: Wed, 9 Sep 2026 01:24:21 +0530 Subject: [PATCH] fix: prevent EOF diagnostic panic without trailing newline --- src/diagnostic/sprite_diagnostics.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/diagnostic/sprite_diagnostics.rs b/src/diagnostic/sprite_diagnostics.rs index 962139a..346fdc2 100644 --- a/src/diagnostic/sprite_diagnostics.rs +++ b/src/diagnostic/sprite_diagnostics.rs @@ -25,17 +25,17 @@ use serde::{ use tsify::Tsify; use super::{ - diagnostic_kind::DiagnosticKind, Diagnostic, + diagnostic_kind::DiagnosticKind, }; use crate::{ ast::Project, codegen::debug_info::DebugInfo, standard_library::StandardLibrary, translation_unit::{ - parse_translation_unit, Owner, TranslationUnit, + parse_translation_unit, }, vfs::VFS, }; @@ -100,7 +100,10 @@ impl SpriteDiagnostics { continue; } // TODO: memoize this using a memoization crate. - let text = fs::read_to_string(&include.path).unwrap(); + let mut text = fs::read_to_string(&include.path).unwrap(); + if !text.ends_with('\n') { + text.push('\n'); + } let include_path = include .path .strip_prefix(cwd)