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

Incorrect code-expander-button when last line is deleted in a diff #29498

Closed
silverwind opened this issue Feb 29, 2024 · 0 comments · Fixed by #29501
Closed

Incorrect code-expander-button when last line is deleted in a diff #29498

silverwind opened this issue Feb 29, 2024 · 0 comments · Fixed by #29501
Labels
topic/ui Change the appearance of the Gitea UI type/bug

Comments

@silverwind
Copy link
Member

silverwind commented Feb 29, 2024

Description

When the last line of a file is deleted, the diff rendering incorrectly shows a code-expander-button below that last line, and clicking it incorrectly expands the first lines of the file after that last line.

https://try.gitea.io/silverwind/symlink-test/commit/96ab2118ae7afd916791a00531016d99e11c2009

Incorrectly displayed button:

image

Incorrect expansion after click:

image

Works fine if the last line is an addition:

https://try.gitea.io/silverwind/symlink-test/commit/24fb688b579af3c75e0d5cefe1ec4bf721585823

image

Gitea Version

main

Can you reproduce the bug on the Gitea demo site?

Yes

@silverwind silverwind added type/bug topic/ui Change the appearance of the Gitea UI labels Feb 29, 2024
silverwind added a commit to silverwind/gitea that referenced this issue Feb 29, 2024
silverwind added a commit that referenced this issue Mar 1, 2024
)

Fixes: #29498

I don't quite understand this code, but this change does seem to fix the
issue and I tested a number of diffs with it and saw no issue. The
function gets such value if last line is an addition:

```
  LastLeftIdx: (int) 0,
  LastRightIdx: (int) 47,
  LeftIdx: (int) 47,
  RightIdx: (int) 48,
```

If it's a deletion, it gets:

```
  LastLeftIdx: (int) 47,
  LastRightIdx: (int) 0,
  LeftIdx: (int) 48,
  RightIdx: (int) 47,
```

So I think it's correct to make this check respect both left and right
side.
DennisRasey pushed a commit to DennisRasey/forgejo that referenced this issue Mar 6, 2024
…501)

Fixes: go-gitea/gitea#29498

I don't quite understand this code, but this change does seem to fix the
issue and I tested a number of diffs with it and saw no issue. The
function gets such value if last line is an addition:

```
  LastLeftIdx: (int) 0,
  LastRightIdx: (int) 47,
  LeftIdx: (int) 47,
  RightIdx: (int) 48,
```

If it's a deletion, it gets:

```
  LastLeftIdx: (int) 47,
  LastRightIdx: (int) 0,
  LeftIdx: (int) 48,
  RightIdx: (int) 47,
```

So I think it's correct to make this check respect both left and right
side.

(cherry picked from commit 3b99066aa866e51e6a610716eaddfd1ea3645a67)
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
topic/ui Change the appearance of the Gitea UI type/bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant