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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

File previews broken due to lack of respect for user's tab-size #6477

Closed
Lamparter opened this issue Apr 9, 2023 · 10 comments 路 Fixed by #6480
Closed

File previews broken due to lack of respect for user's tab-size #6477

Lamparter opened this issue Apr 9, 2023 · 10 comments 路 Fixed by #6480

Comments

@Lamparter
Copy link

Description

On XML based languages, Refined GitHub renders the code in weird ways:
Seemingly, it puts in more spacing than is usual, so there is a remain of the code in it's 'usual' state.
Not so sure about this one.

馃摑 Note that this only occurs when selecting text.

Second of all, the text selector can only go to the end of the 'original' black text and not of the white one, so I cannot visually select the whole text.

I have a video of this, but could not upload it to GitHub.
image
See:
https://riversidevalley-my.sharepoint.com/:v:/g/personal/lamparter_theriversi_de/EdcPsBJFcslMlVmICHSqgK0B_k0xd72Ep1hu9Tk35qFZoA?e=Dieyoo
This video is of https://github.com/files-community/Website/blob/cfcfa9098860261e4433eecc77ae80b2c0e8d281/src/i18n/locales/en-US.json

How to replicate the issue + URL

Seemingly occurs in HTML/XML based languages, such as Svelte, XAML and of course, HTML, as well as JSON (a lot of web languages! but not Ruby); I have used the Refined GitHub feature identifier and it did not identify the problem, however disabling the Refined GitHub extension does fix the problem.

Example: https://github.com/RiversideValley/Website/blob/main/src/app.html
image

Extension version

23.3.31

Browser(s) used

Microsoft Edge Insider Dev

@Lamparter Lamparter added the bug label Apr 9, 2023
@fregante
Copy link
Member

fregante commented Apr 9, 2023

This is likely a combination of:

  • GitHub is playing with a hidden/duplicate element first mentioned here
  • your tab size is set to 8 characters
  • our tab-size affects only the hidden element

As a temporary fix:

@fregante
Copy link
Member

fregante commented Apr 9, 2023

cc @kidonng

@fregante fregante self-assigned this Apr 9, 2023
@fregante
Copy link
Member

fregante commented Apr 9, 2023

I can replicate the issue because my tab size is also not 4 characters and I have the new hidden element.

Screenshot

Screenshot 1

I'll push a hotfix

fregante added a commit to refined-github/yolo that referenced this issue Apr 9, 2023
fregante added a commit to refined-github/yolo that referenced this issue Apr 9, 2023
@fregante
Copy link
Member

fregante commented Apr 9, 2023

Hotfixed, no further action required on your part, just wait a few hours

@fregante fregante removed their assignment Apr 9, 2023
@kidonng
Copy link
Member

kidonng commented Apr 9, 2023

Caused by

* {
tab-size: var(--tab-size) !important;
}

overriding

<textarea
	id="read-only-cursor-text-area"
	style="tab-size: <what-you-set-in-your-preference>"
>

* is probably too wide. Just use more specific selector?

Also this is annoying:

image

@fregante
Copy link
Member

fregante commented Apr 9, 2023

Just use more specific selector?

Yeah back then we kept this to cover any situations that GitHub forgot:

It seems that they still haven't been fixed. Maybe the new selector is just .markdown-body pre but we need to re-verify if anything else is needed here: https://github.com/refined-github/refined-github/blob/main/source/features/tab-size.css

Some code is also needed to preserve show-whitespace

@fregante
Copy link
Member

fregante commented Apr 9, 2023

It seems that this was reported yesterday but I closed it as unreproducible:

@kidonng
Copy link
Member

kidonng commented Apr 9, 2023

We only really care tabs in two places:

  • Code view (natively supported, both on main site and Gist)
  • User content (.markdown-body)

Oh, maybe action logs?

@fregante
Copy link
Member

fregante commented Apr 9, 2023

  • User content (.markdown-body)

I think yeah let's target this, like suggested in my previous comment.

Oh, maybe action logs?

Would be ideal, but I don鈥檛 think it's common to print tabs in the console and especially not expecting them to be 8 characters, so probably it's best to not touch that.

@Lamparter Lamparter changed the title Refined GitHub destroys file previews (feature unidentifiable) File previews broken due to lack of respect for user's tab-size Apr 9, 2023
@Lamparter
Copy link
Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

3 participants