From f95e0835901cb56e61fbbcd01d09eb9ee4963f8f Mon Sep 17 00:00:00 2001 From: JHertz5 Date: Sat, 23 May 2026 13:39:12 +0100 Subject: [PATCH] Issue#1547: Corrected get_index_of_line for when there is no previous line. --- vsg/token_map.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/vsg/token_map.py b/vsg/token_map.py index b86ef750..d17a4537 100644 --- a/vsg/token_map.py +++ b/vsg/token_map.py @@ -146,7 +146,13 @@ class New: pp.pprint(self.dMap) def get_index_of_line(self, iLine): - return self.dMap["parser"]["carriage_return"][iLine - 2] + 1 + # This function works by getting the carriage return from the previous line and adding 1 to make it the start of + # the next line. If the input is the first line, then there is not previous line, so there is a special case is + # required. + if iLine == 1: + return 0 + else: + return self.dMap["parser"]["carriage_return"][iLine - 2] + 1 def extract_unique_id(oToken):