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

Show 🚫 on the last line when a file does not end with \n #27391

Closed
wants to merge 4 commits into from

Conversation

wxiaoguang
Copy link
Contributor

@wxiaoguang wxiaoguang commented Oct 2, 2023

Follow my comment #19967 (comment)

If users want to hide the last empty line or show a block emoji (🚫) for no-newline when rendering, the new code is easier to do so in the future.

Changed the line-counting behavior to not count the last empty line on the UI. And add the "no EOL" mark to the last line.

// Gitea uses the definition (like most modern editors):
//   empty: 0 lines; "a": 1 line; "a\n": 2 lines (only 1 line is rendered); "a\nb": 2 lines;
//   When rendering, the last empty line is not rendered on UI, so "a\n" will be only rendered as one line on the UI.
//   If the content doesn't end with an EOL, there will be an icon mark at the end of last line to distinguish from the case above.

image

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Oct 2, 2023
@pull-request-size pull-request-size bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Oct 2, 2023
@wxiaoguang wxiaoguang changed the title Show an no-EOL mark for the last line when viewing a file Show a no-EOL mark for the last line when viewing a file Oct 2, 2023
@github-actions github-actions bot added the topic/ui Change the appearance of the Gitea UI label Oct 2, 2023
@wxiaoguang wxiaoguang added this to the 1.22.0 milestone Oct 2, 2023
@wxiaoguang wxiaoguang added the type/enhancement An improvement of existing functionality label Oct 2, 2023
@delvh delvh added the backport/v1.21 This PR should be backported to Gitea 1.21 label Oct 2, 2023
@delvh delvh changed the title Show a no-EOL mark for the last line when viewing a file Show 🚫 on the last line when a file does not end with \n Oct 2, 2023
@wxiaoguang
Copy link
Contributor Author

Show 🚫 ....

@delvh I am not a fan of putting emoji chars into the git message, especially in the "title"

@delvh
Copy link
Member

delvh commented Oct 2, 2023

I know, me neither.
But what's the alternative?
An unreadable title?

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Oct 2, 2023
templates/repo/view_file.tmpl Outdated Show resolved Hide resolved
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Oct 2, 2023
@silverwind
Copy link
Member

silverwind commented Oct 2, 2023

I changed it to octicon and added tooltip. Because this is a SVG, text selection can now start over the icon as well:

image

@silverwind
Copy link
Member

silverwind commented Oct 2, 2023

I think we are doing this wrong:

  • Gitea shows the icon in file view, but not in diff view (after this PR)
  • GitHub does not show it in file view but does show it in diff view

I find it much more important in diffs and I may actually find it annoying in file view.

@wxiaoguang
Copy link
Contributor Author

Leave it to the future. Actually the old UI also looks good to me.

@wxiaoguang wxiaoguang closed this Oct 3, 2023
@wxiaoguang wxiaoguang deleted the improve-file-eol branch October 3, 2023 00:44
@wxiaoguang wxiaoguang removed this from the 1.22.0 milestone Oct 3, 2023
@wxiaoguang wxiaoguang removed lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. backport/v1.21 This PR should be backported to Gitea 1.21 labels Oct 3, 2023
@delvh
Copy link
Member

delvh commented Oct 3, 2023

The PR was closed?
Not merged?
😕

@silverwind
Copy link
Member

Because of #27391 (comment). I think it's better we only have it in diff view, not in file view.

@delvh
Copy link
Member

delvh commented Oct 3, 2023

I mean, at best in both for consistency, but I would have accepted it in only one as well.

@wxiaoguang
Copy link
Contributor Author

Why I wrote this PR?

There were some discussions about the consistency of "line number" and rendered lines.

I feel that it could be improved by such approach, and I was killing my time on the train.

Why it is closed?

The old approach also looks good to me, nothing really bothers me, and I do not have time to make future improvements to satisfy every user.

@silverwind
Copy link
Member

silverwind commented Oct 3, 2023

I mean, at best in both for consistency, but I would have accepted it in only one as well.

I think less is more. During review, a EOL change is significant enough to be highlighted, but seeing this icon in file view will get annoying soon as you may be inclined to think something is wrong with the file when it really isn't.

@go-gitea go-gitea locked as resolved and limited conversation to collaborators Jan 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
size/L Denotes a PR that changes 100-499 lines, ignoring generated files. topic/ui Change the appearance of the Gitea UI type/enhancement An improvement of existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants