Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fix(table): unset data rows without causing nil pointer err #372

Merged
merged 2 commits into from
Oct 3, 2024

Conversation

bashbunni
Copy link
Member

@bashbunni bashbunni commented Sep 20, 2024

Without this change data is set to nil causing nil ptr errors whenever we want to add data to the table after calling ClearRows. Instead, this function should reset the values without clearing the data type so it's still usable

@meowgorithm
Copy link
Member

Okay cool. So basically if you call ClearRows() and then try and add more data we get a nil pointer exception, right?

table := New().
		Border(lipgloss.NormalBorder()).
		Headers("LANGUAGE", "FORMAL", "INFORMAL").
		Row("Chinese", "Nǐn hǎo", "Nǐ hǎo")
	table.ClearRows() // Right here
	table.Row("French", "Bonjour", "Salut")

@bashbunni
Copy link
Member Author

@meowgorithm yes, exactly! Or when you would call String() it would try and check the length of rows and get a nil pointer error because the value is nil instead of an array or slice

@meowgorithm
Copy link
Member

This is a great catch 🙏

@bashbunni bashbunni merged commit b08e7e4 into master Oct 3, 2024
10 checks passed
@caarlos0 caarlos0 deleted the fix-clearRows branch October 3, 2024 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
3 participants