fix: edge case where buffer is added two times to buffers component #1134
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The total length check for the buffers component first checks if it has enough space to add a before buffer, then adds it and then checks it for buffers after the current one. If that second check fails the before buffer is added a second time to the buffer component, this time as an ellipsis which can lead to confusing behavior and unwanted visual artifacts. This commit fixes this problem.
Here is a screenshot to better illustrate the issue. Note the missing bar after the ellipsis:
Before:
![2023-11-03-084028_557x33_scrot](https://private-user-images.githubusercontent.com/53401822/280212775-f45e8420-9f13-4918-8695-26d78f41c0d7.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTg2OTM1MzQsIm5iZiI6MTcxODY5MzIzNCwicGF0aCI6Ii81MzQwMTgyMi8yODAyMTI3NzUtZjQ1ZTg0MjAtOWYxMy00OTE4LTg2OTUtMjZkNzhmNDFjMGQ3LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MTglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjE4VDA2NDcxNFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTc2YmRhYzA4NmVmNjMxOGNkODk4ZWY0OGNlOTQ3ZGJiNjA2NzhmMzg5NDI0MmViZGU0NzE3M2JhMGFmNTNmYjYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.lbYVSHbUG3WLC6mfQsfPYBwDMRd3_sBV1Ou0DoYlKMs)
After:
![2023-11-03-084123_570x31_scrot](https://private-user-images.githubusercontent.com/53401822/280212867-1f64d2d0-3e48-4616-bd29-c333ea4eccdf.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTg2OTM1MzQsIm5iZiI6MTcxODY5MzIzNCwicGF0aCI6Ii81MzQwMTgyMi8yODAyMTI4NjctMWY2NGQyZDAtM2U0OC00NjE2LWJkMjktYzMzM2VhNGVjY2RmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MTglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjE4VDA2NDcxNFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPThkMTA1MTdkNTI5MmJkMzBmMDViNTg2NzQ5NzI5MjE4MWE4MzdjMWQ5OWExN2EyODNmMjhmYmU0N2E4ZWRhOWYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.1C_lWhcVgUVJbo-6oLNfO3mFChFmyK9iR0YAgcZxWmE)