You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Richard Mahn 98f7013756
Prevent NPE in CSV diff rendering when column removed (#17018)
Fixes #16837 if a column is deleted.

We were clobbering the columns that were added by looping through the aline (base) and then when bline (head) was looped through, it clobbered what was in the "cells" array that is show in the diff, and then left a nil cell because nothing was shifted.

This fix properly shifts the cells, and properly puts the b cell either at its location or after, according to what the aline placed in the cells.

This includes test, adding a new test function since adding/removing cells works best with three columns, not two, which results in 4 columns of the resulting cells because it has a deleted column and an added column. If you try this locally, you can try those cases and others, such as adding a column.

There was no need to do anything special for the rows when `aline == 0 || bline == 0` so that was removed. This allows the same code to be used for removed or added lines, with the bcell text always being the RightCell, acell text being the LeftCell.

I still added the patch zeripath gave at https://github.com/go-gitea/gitea/issues/16837#issuecomment-913007382 so that just in case for some reason a cell is nil (which shouldn't happen now) it doesn't throw a 500 error, so the user can at least view the raw diff.

Also fixes in the [view.go](https://github.com/go-gitea/gitea/pull/17018/files#diff-43a7f4747c7ba8bff888c9be11affaafd595fd55d27f3333840eb19df9fad393L521) file how if a CSV file is empty (either created empty or if you edit it and remove all contents) it throws a huge 500 error when you then save it (when you view the file). Since we allow creating, saving and pushing empty files, we shouldn't throw an error on an empty CSV file, but just show its empty contents. This doesn't happen if it is a Markdown file or other type of file that is empty.
EDIT: Now handled in the markup/csv renderer code
3 years ago
..
chroma Improve Light Chroma style (#15699) 3 years ago
code Fix and restyle menu on code line (#15913) 3 years ago
features Kanban colored boards (#16647) 3 years ago
markup Force color-adjust for markdown checkboxes (#17146) 3 years ago
shared Issue list alignment tweaks (#15483) 3 years ago
standalone Fix tooltips and issue dependency styles (#13458) 4 years ago
themes Prevent NPE in CSV diff rendering when column removed (#17018) 3 years ago
_admin.less Fix webhook list styling (#14001) 4 years ago
_base.less Prevent NPE in CSV diff rendering when column removed (#17018) 3 years ago
_dashboard.less Fix overflow label in mobile view (#17020) 3 years ago
_editor.less Issue sidebar and misc css fixes (#15524) 3 years ago
_explore.less Ensure popup text is aligned left (#17327) 3 years ago
_font_i18n.less Fix CJK fonts again and misc. font issues (#14575) 3 years ago
_form.less Branch page and misc css improvements (#15208) 3 years ago
_home.less fix media query edge case (#13546) 4 years ago
_install.less Reindent Less to 2-space (#12602) 4 years ago
_organization.less Fix margin between avatars on org pages (#15194) 3 years ago
_repository.less Prevent NPE in CSV diff rendering when column removed (#17018) 3 years ago
_review.less fix: code review comments on mobile (#17321) 3 years ago
_svg.less Reindent Less to 2-space (#12602) 4 years ago
_tribute.less Update JS dependencies (#15033) 3 years ago
_user.less Remove remaining fontawesome usage in templates (#15952) 3 years ago
helpers.less Fix various documentation, user-facing, and source comment typos (#16367) 3 years ago
index.less Fix and restyle menu on code line (#15913) 3 years ago
misc.css Raw file view tweaks (#15520) 3 years ago
variables.less fix media query edge case (#13546) 4 years ago