Why does APVTS::ParameterAdapter::getTextForDenormalisedValue call the conversion function with length 0?

I just ran into the following issue:

I pass a stringFromValue function as the appropriate argument to a AudioParameterFloat constructor. The function looks like

juce::String MyParameters::AllRotaries::stringFromValueConversion (float value, int maximumStringLength)
    return stringWithMaxLength (juce::String (10.0f * value), maximumStringLength);

where stringWithMaxLength is a function that currently simply truncates a string that’s longer than maximumStringLength to the allowed max length. Now I noticed that my sliders popup display is empty. Setting a breakpoint into the conversion function and stepping up the call stack a bit I find this call, which calls the conversion function with a string length of 0

This leads to an empty string being returned. Looking at the documentation, I find no mention of e.g. a value of 0 meaning “no limit” or similar. Can I safely assume that a value of 0 should indeed mean no limit and if so, where do I find this in the docs? Or do I get something terribly wrong here?

In the constructor of AudioParameterFloat, there’s a default implementation:

stringFromValueFunction = [numDecimalPlacesToDisplay] (float v, int length)
    String asText (v, numDecimalPlacesToDisplay);
    return length > 0 ? asText.substring (0, length) : asText;

So it does seem like 0 is used to indicate no limit.

Ah didn’t see that. Well the second line of that function is essentially exactly the content of my stringWithMaxLength function now :smiley:

I still would like to find out where that value is documented, internal implementations may change somewhen so I always prefer to rely on some explicitly stated behaviour