diff --git a/src/protocol/input_source.rs b/src/protocol/input_source.rs index f2cf10693ae87bc134610829d91344bcc1f221f1..c2c7cd164eea9c9e433e2ecd569b4c65de2ae4ee 100644 --- a/src/protocol/input_source.rs +++ b/src/protocol/input_source.rs @@ -170,6 +170,13 @@ impl InputSource { return lookup; } + /// Retrieves the column associated with a line. Calling this incurs a read + /// lock, so don't spam it in happy-path compiler code. + pub(crate) fn get_column(&self, pos: InputPosition) -> u32 { + let line_start = self.lookup_line_start_offset(pos.line); + return pos.offset - line_start + 1; + } + /// Retrieves offset at which line starts (right after newline) fn lookup_line_start_offset(&self, line_number: u32) -> u32 { let lookup = self.get_lookup();