added support for shebangs: if the file starts with "#!", the first line will be ignored.

This commit is contained in:
Dummi26 2023-04-20 19:37:29 +02:00
parent 5bb4d2e4a5
commit ed8aecde86

View File

@ -32,6 +32,11 @@ impl Display for FilePosition {
impl File { impl File {
pub fn new(data: String, path: PathBuf) -> Self { pub fn new(data: String, path: PathBuf) -> Self {
let data = if data.starts_with("#!") {
&data[data.lines().next().unwrap().len()..].trim_start()
} else {
data.trim_start()
};
let mut chs = data.chars(); let mut chs = data.chars();
let mut data = String::with_capacity(data.len()); let mut data = String::with_capacity(data.len());
loop { loop {