mechatroner / atom-rainbow-csv

:rainbow: Atom package: Highlight CSV and TSV spreadsheet files in different rainbow colors
MIT License
16 stars 0 forks source link

How not to get error on adding a coma without having header #8

Closed hugo13122000 closed 4 years ago

hugo13122000 commented 4 years ago

I did some research on the web although I don't code JS, a stack overflow thread allowed me to add a line fixing the error :

i just added after line 71 :

if (elem === null) return;
function get_column_color(col_num) {
    let css_class_name = '.syntax--rainbow' + (col_num % num_rainbow_colors + 1);
    let elem = document.querySelector(css_class_name);

    if (elem === null) 
        return;

let style = getComputedStyle(elem);
    return style.color;
}

it is now working properly

EDIT : The error was linked to adding coma when there's no header yet however, this fix allows you to do so without getting an error

Originally posted by @hugo13122000 in https://github.com/mechatroner/atom-rainbow-csv/issues/7#issuecomment-557181392