Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Rows with different content causes table failure #60

Open
rocketraman opened this issue Dec 16, 2023 · 0 comments
Open

Rows with different content causes table failure #60

rocketraman opened this issue Dec 16, 2023 · 0 comments

Comments

@rocketraman
Copy link

rocketraman commented Dec 16, 2023

I have a case in which I have rows with different content. For example, some rows use a dash for a value if it is not applicable, while other rows may have a numeric value.

It seems like ktformat uses an "example row" to decide what formatting to apply to every row, but this then results in an exception like this:

java.lang.IllegalArgumentException: Can not format value '—' of type 'class java.lang.String 'using format spec '%-8d'

This seems like a common use case that it would be nice to handle elegantly. Perhaps one way to do it is to provide value converters as hints. If such a hint was provided, it would be used to transform the value for display rather than the example row.

The workaround is to ensure all values added to a row are consistent i.e. numeric values are converted to Strings in advance, so that the example row has consistent types with every other row.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant