Closed user202729 closed 3 months ago
@johncbowman Are you sure that change will work correctly? Because you're not adjusting the location of the ^
sign either.
I did actually test the change with just 1 space, but at the last minute decided to change the tab to 2 spaces, which in hindsight was a mistake, as you point out.
By the way, for reasons like this, it is generally recommended not to use tab characters in code. Tabs are useful for data/code entry but you should set your editor to automatically untabify (converted them to spaces).
Re. tab versus space, it's opinion-based (https://stackoverflow.com/questions/7728829/what-is-the-difference-between-using-tab-and-space-when-we-do-source-code-format https://stackoverflow.com/questions/120926/why-does-python-pep-8-strongly-recommend-spaces-over-tabs-for-indentation ) so I wouldn't argue on that.
Anyway, I suppose you can do something like the following
auto part_before_cursor = s.substr(0, pos.column), part_after_cursor = s.substr(pos.column);
part_before_cursor = std::regex_replace(part_before_cursor,std::regex("\t")," ");
part_after_cursor = std::regex_replace(part_after_cursor,std::regex("\t")," ");
out << string(part_before_cursor.length(), ' ') << '^';
adapted as needed (I'm not sure if the two construction of std::regex
is costly etc.)
For what it's worth, I think gcc (the compiler) replaces each tab with 8 spaces for the purpose of display.
The error message in https://github.com/vectorgraphics/asymptote/issues/443 looks confusing because the tab is counted as 1 character by the arrow.