g2384 / VHDLFormatter

VHDL formatter web online written in typescript
https://g2384.github.io/VHDLFormatter/
MIT License
51 stars 20 forks source link

Characters such as '-' are affected by the formatting #8

Closed goglecm closed 6 years ago

goglecm commented 6 years ago

Here is the original code

    function to_string(
        a : data_bit_vector
    ) return string is
        variable result : string(1 to a'length) := (others => '-');
    begin
        return result;
    end function to_string;

and here is how it gets formatted

function to_string(
    a : data_bit_vector
) return string is
    variable result : string(1 to a'length) := (others => ' - ');
begin
    return result;
end function to_string;

The issue is that (others => '-') gets formatted to (others => ' - '). As you can see there is a pair of spaces around the - sign. This is not correct and it throws an error as the compiler expects only one character. The same occurs with +, *, etc. So the fix would be to not apply formatting for single characters in between single quotes.

g2384 commented 6 years ago

Fixed