From f3ef874b088e10caeb28d0fc7597c13fb83499de Mon Sep 17 00:00:00 2001 From: mechatroner Date: Tue, 24 May 2022 22:24:30 -0400 Subject: [PATCH] #36 - add config option to support zero-based column enumeration --- RainbowCSV.sublime-settings | 4 ++++ main.py | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/RainbowCSV.sublime-settings b/RainbowCSV.sublime-settings index 7f79406..90c7f68 100644 --- a/RainbowCSV.sublime-settings +++ b/RainbowCSV.sublime-settings @@ -20,6 +20,10 @@ // Allow quoted multiline fields as defined in RFC-4180: https://tools.ietf.org/html/rfc4180 "allow_newlines_in_fields": false, + // Use zero-based column indices in hover column info. + // This doesn't affect column naming in RBQL queries. + "use_zero_based_column_indices": false, + // Use custom high-contrast rainbow colors instead of colors provided by your current color scheme. // When you enable this option, "auto_adjust_rainbow_colors" also gets enabled by default. "use_custom_rainbow_colors": false, diff --git a/main.py b/main.py index 079f33e..33c9cff 100644 --- a/main.py +++ b/main.py @@ -1038,13 +1038,14 @@ def on_hover(self, point, hover_zone): field_num = get_col_num_single_line(hover_record, len(delim), cnum) if len(header) != len(hover_record): inconsistent_num_fields_warning = True - ui_text = 'Col #{}'.format(field_num + 1) + use_zero_based_column_indices = get_setting(self.view, 'use_zero_based_column_indices', False) + ui_text = 'Col {}'.format(field_num if use_zero_based_column_indices else field_num + 1) if field_num < len(header): column_name = header[field_num] max_header_len = 30 if len(column_name) > max_header_len: column_name = column_name[:max_header_len] + '...' - ui_text += ', Header: "{}"'.format(column_name) + ui_text += ', {}'.format(column_name) if inconsistent_num_fields_warning: ui_text += '; WARN: num of fields in Header and this line differs' if quoting_warning: