bench-forgejo/web_src/less
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
2021-10-20 20:10:03 +01:00
..
chroma Improve Light Chroma style (#15699) 2021-05-02 22:43:08 -04:00
code Fix and restyle menu on code line (#15913) 2021-05-18 23:16:02 -04:00
features Kanban colored boards (#16647) 2021-09-29 22:53:12 +02:00
markup Force color-adjust for markdown checkboxes (#17146) 2021-09-25 14:45:55 +08:00
shared Issue list alignment tweaks (#15483) 2021-05-05 12:57:59 -04:00
standalone Fix tooltips and issue dependency styles (#13458) 2020-11-10 20:28:07 +02:00
themes Prevent NPE in CSV diff rendering when column removed (#17018) 2021-10-20 20:10:03 +01:00
_admin.less Fix webhook list styling (#14001) 2020-12-16 19:22:21 +01:00
_base.less Prevent NPE in CSV diff rendering when column removed (#17018) 2021-10-20 20:10:03 +01:00
_dashboard.less Fix overflow label in mobile view (#17020) 2021-09-12 13:40:20 +02:00
_editor.less Issue sidebar and misc css fixes (#15524) 2021-05-16 22:18:18 +02:00
_explore.less Ensure popup text is aligned left (#17327) 2021-10-17 11:14:32 +01:00
_font_i18n.less Fix CJK fonts again and misc. font issues (#14575) 2021-03-19 00:43:43 +01:00
_form.less Branch page and misc css improvements (#15208) 2021-04-03 10:37:32 +02:00
_home.less fix media query edge case (#13546) 2020-11-17 00:33:19 -05:00
_install.less Reindent Less to 2-space (#12602) 2020-08-25 22:48:53 +03:00
_organization.less Fix margin between avatars on org pages (#15194) 2021-03-29 20:57:27 +01:00
_repository.less Prevent NPE in CSV diff rendering when column removed (#17018) 2021-10-20 20:10:03 +01:00
_review.less fix: code review comments on mobile (#17321) 2021-10-16 10:22:24 +08:00
_svg.less Reindent Less to 2-space (#12602) 2020-08-25 22:48:53 +03:00
_tribute.less Update JS dependencies (#15033) 2021-03-22 05:04:19 +01:00
_user.less Remove remaining fontawesome usage in templates (#15952) 2021-05-22 23:29:46 +02:00
helpers.less Fix various documentation, user-facing, and source comment typos (#16367) 2021-07-08 13:38:13 +02:00
index.less Fix and restyle menu on code line (#15913) 2021-05-18 23:16:02 -04:00
misc.css Raw file view tweaks (#15520) 2021-04-22 23:43:44 +02:00
variables.less fix media query edge case (#13546) 2020-11-17 00:33:19 -05:00