Skip to content

Incorrect tab size in GitHub diff UI #3055

Closed

Description

@notlmn

Explanation

This is a restriction of tab characters being collapsed to nearest tab point because of that extract character at the start of the line.

Here is an example:

$ git diff master
diff --git a/source/refined-github.css b/source/refined-github.css
index 8d7a559..3d8cdd5 100644
--- a/source/refined-github.css
+++ b/source/refined-github.css
@@ -114,3 +114,22 @@ pr-branches
 .js-issue-row .text-small.text-gray {
        line-height: 1.8;
 }
+
+/* Removes redundant user/repo from notifications when being grouped by repository */
+/* Place discussion number before the title */
+.js-notifications-group [id^='notification'] {
+       flex-direction: row !important;
+}
+/* Hide duplicate repository URL */
+.js-notifications-group [id^='notification'] > .d-flex > .f6 {
+       font-size: 0 !important;
+}
+/* Size and position the discussion number */
+.js-notifications-group [id^='notification'] > .d-flex > .f6 > span {
+       display: block;
+       font-size: 12px;
+       font-variant-numeric: tabular-nums;
+       margin-top: 2px; /* Align baseline with discussion title */
+       margin-right: 8px;
+       word-break: keep-all;
+}

Here Git renders a tab character with 7 spaces, 1 for the marker at the front. This is a limitation (if you could say that) on terminals, but ideally should not be on the web where we have much more control.

This is especially noticeable when we have tab-size set to 4 with this extension, now we have the first tab character of each line being rendered to only 2 physical spaces.

We kinda solved this with remove-diff-signs, where we added the ability to remove markers completely from the DOM flow, restoring the tab translation to 4 as intended. But after #2970, this issue got introduced again, with the diff markers interfering with the tab characters at the start of the line.

Reproduction

How should this be solved?

remove-diff-signs should remove diff markers from the DOM flow completely, as it used to do before, letting tabs flow as if they are the first character on the line.

How would we solve #2970 then? Remove negative text indentation mentioned above.

Activity

  1. added
    Please! ♥︎
    and removed on May 3, 2020
  2. removed
    Please! ♥︎
    on May 3, 2020
  3. fregante commented on May 3, 2020

    @fregante
    Member

    I'll simplify: In diffs, the first tab on each line appears to be 2 characters instead of 4.

    Live example and screenshot:

    This happens because in diffs there are 2 extra characters at the beginning of each line. The first tab includes these, but shouldn't.


    This is unrelated to existing features, but it's a pre-existing GitHub bug that Refined GitHub highlights and could fix.

  4. fregante commented on May 3, 2020

    @fregante
    Member

    remove-diff-signs should remove diff markers from the DOM flow completely

    This is dangerous and not advised. We used to do that before it became possible via CSS and it caused a lot of headaches.

    I might have found a CSS solution, but needs testing

  5. fregante commented on May 6, 2020

    @fregante
    Member

    It doesn't work well in unified view. It needs further work and testing.

    CSS-only PR welcome starting with the code from #3058

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions