diff --git a/src/errors.rs b/src/errors.rs index 579e50f..c6014c0 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -132,14 +132,14 @@ pub fn create_error(message: &str, position: usize, typ: ErrorType, stype: Error fn get_exact_pos(file: &String, pos: usize) -> (usize, usize) { let mut line = 1; - let mut column = 0; - for (i, c) in file.char_indices() { - if i == pos { + let mut column = 1; + for (i, c) in file.chars().enumerate() { + if i == pos-1 { return (line, column); } if c == '\n' { line += 1; - column = 0; + column = 1; } else { column += 1; }