mirror of
1
Fork 0
forgejo/models
forgejo-backport-action 118762dd6d [v8.0/forgejo] fix(UI): issue task list numbers, fix #4431 (#4735)
**Backport:** https://codeberg.org/forgejo/forgejo/pulls/4452

## Regexp fixes
This fixes #4431 by adjusting the related regular expressions. Also it allows to have multiple spaces between `-` or `*` and the following brackets.

Related is the following gitea PR: https://github.com/go-gitea/gitea/pull/3296. I wonder a bit why the author stated
> Also fixed the requirement for one character after the blank of - [ ] .

I don't see a reason why
```
- [x]
some task
```
shall not be a valid checkbox without any character after the `]`. E.g., this would render to
- [x]
some task

The third commit fixes this issue.

### Comments
- I wonder a bit why the regexp is written in such complicated way and if
  ```diff
  - (^\s*[-*]\s*\[[\sxX]\])|(
\s*[-*]\s*\[[\sxX]\])
  + (^|
)\s*[-*]\s*\[[\sxX]\]
  ```
  would work the same way. Edit: I tried and indeed the second regex works as expected.
- ~~Why it is actually matching the `\s` and not just the space (` `)? (but OK, no big issue)~~ Edit: `[\t]` is also allowed. Keep it!
- Check boxes in code blocks are counted as well, but I think that this is an edge case which is not a big issue as well.

### Before
![before](https://codeberg.org/attachments/cb4f879d-cdd2-4814-aed2-5de8b5437fb2)
### After
![after](https://codeberg.org/attachments/5d54648f-dd73-4577-9a80-729016219093)

## Javascript fixes
Additionally, while testing I figured out, that currently checkboxes with capital `X` like
```
- [X] another task
```
- [X] another task

cannot be unchecked. Thus, the second commit fixes that issue as well.

## Checklist

The [developer guide](https://forgejo.org/docs/next/developer/) contains information that will be helpful to first time contributors. There also are a few [conditions for merging Pull Requests in Forgejo repositories](https://codeberg.org/forgejo/governance/src/branch/main/PullRequestsAgreement.md). You are also welcome to join the [Forgejo development chatroom](https://matrix.to/#/#forgejo-development:matrix.org).

### Tests

- I added test coverage for Go changes...
  - [ ] in their respective `*_test.go` for unit tests.
  - [x] in the `tests/integration` directory if it involves interactions with a live Forgejo server.
- I added test coverage for JavaScript changes...
  - [ ] in `web_src/js/*.test.js` if it can be unit tested.
  - [ ] in `tests/e2e/*.test.e2e.js` if it requires interactions with a live Forgejo server (see also the [developer guide for JavaScript testing](https://codeberg.org/forgejo/forgejo/src/branch/forgejo/tests/e2e/README.md#end-to-end-tests)).

### Documentation

- [ ] I created a pull request [to the documentation](https://codeberg.org/forgejo/docs) to explain to Forgejo users how to use this change.
- [x] I did not document these changes and I do not expect someone else to do it.

### Release notes

- [ ] I do not want this change to show in the release notes.
- [x] I want the title to show in the release notes with a link to this pull request.
- [ ] I want the content of the `release-notes/<pull request number>.md` to be be used for the release notes instead of the title.

Co-authored-by: Robert Wolff <mahlzahn@posteo.de>
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4735
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
Co-authored-by: forgejo-backport-action <forgejo-backport-action@noreply.codeberg.org>
Co-committed-by: forgejo-backport-action <forgejo-backport-action@noreply.codeberg.org>
2024-07-31 14:16:11 +00:00
..
actions enable linter testifylint on v8 (#4573) 2024-07-30 19:41:27 +00:00
activities enable linter testifylint on v8 (#4573) 2024-07-30 19:41:27 +00:00
admin Next round of `db.DefaultContext` refactor (#27089) 2023-09-16 14:39:12 +00:00
asymkey enable linter testifylint on v8 (#4573) 2024-07-30 19:41:27 +00:00
auth enable linter testifylint on v8 (#4573) 2024-07-30 19:41:27 +00:00
avatars enable linter testifylint on v8 (#4573) 2024-07-30 19:41:27 +00:00
db enable linter testifylint on v8 (#4573) 2024-07-30 19:41:27 +00:00
dbfs enable linter testifylint on v8 (#4573) 2024-07-30 19:41:27 +00:00
fixtures Fixed link to commit status and tooltip on dashboard 2024-07-14 17:39:35 +00:00
forgefed enhance test & fix reviews 2024-05-14 08:24:31 +02:00
forgejo/semver enable linter testifylint on v8 (#4573) 2024-07-30 19:41:27 +00:00
forgejo_migrations enable linter testifylint on v8 (#4573) 2024-07-30 19:41:27 +00:00
git enable linter testifylint on v8 (#4573) 2024-07-30 19:41:27 +00:00
issues [v8.0/forgejo] fix(UI): issue task list numbers, fix #4431 (#4735) 2024-07-31 14:16:11 +00:00
migrations enable linter testifylint on v8 (#4573) 2024-07-30 19:41:27 +00:00
organization enable linter testifylint on v8 (#4573) 2024-07-30 19:41:27 +00:00
packages enable linter testifylint on v8 (#4573) 2024-07-30 19:41:27 +00:00
perm enable linter testifylint on v8 (#4573) 2024-07-30 19:41:27 +00:00
project enable linter testifylint on v8 (#4573) 2024-07-30 19:41:27 +00:00
pull [GITEA] GetScheduledMergeByPullID may involve a system user 2024-02-05 16:09:41 +01:00
repo enable linter testifylint on v8 (#4573) 2024-07-30 19:41:27 +00:00
secret Make runs-on support variable expression (#29468) 2024-03-11 23:36:59 +07:00
shared/types Refactor locale&string&template related code (#29165) 2024-02-16 15:20:52 +01:00
system enable linter testifylint on v8 (#4573) 2024-07-30 19:41:27 +00:00
unit enable linter testifylint on v8 (#4573) 2024-07-30 19:41:27 +00:00
unittest enable linter testifylint on v8 (#4573) 2024-07-30 19:41:27 +00:00
user enable linter testifylint on v8 (#4573) 2024-07-30 19:41:27 +00:00
webhook enable linter testifylint on v8 (#4573) 2024-07-30 19:41:27 +00:00
error.go Add merge style `fast-forward-only` (#28954) 2024-02-14 17:19:19 +01:00
fixture_generation.go Replace more db.DefaultContext (#27628) 2023-10-15 17:46:06 +02:00
fixture_test.go enable linter testifylint on v8 (#4573) 2024-07-30 19:41:27 +00:00
main_test.go enable linter testifylint on v8 (#4573) 2024-07-30 19:41:27 +00:00
org.go Refactor deletion (#28610) 2023-12-25 21:25:29 +01:00
org_team.go Remove GetByBean method because sometimes it's danger when query condition parameter is zero and also introduce new generic methods (#28220) 2023-12-07 15:27:36 +08:00
org_team_test.go enable linter testifylint on v8 (#4573) 2024-07-30 19:41:27 +00:00
org_test.go enable linter testifylint on v8 (#4573) 2024-07-30 19:41:27 +00:00
repo.go Refactor deletion (#28610) 2023-12-25 21:25:29 +01:00
repo_test.go enable linter testifylint on v8 (#4573) 2024-07-30 19:41:27 +00:00
repo_transfer.go chore: use errors.New to replace fmt.Errorf with no parameters will much better (#30621) 2024-04-28 15:39:00 +02:00
repo_transfer_test.go enable linter testifylint on v8 (#4573) 2024-07-30 19:41:27 +00:00