`one-click-diff-options` - Restore `d w` shortcut in PRs by fregante · Pull Request #9262 · refined-github/refined-github · GitHub
Skip to content

one-click-diff-options - Restore d w shortcut in PRs#9262

Merged
fregante merged 2 commits into
mainfrom
one-click-options
Apr 25, 2026
Merged

one-click-diff-options - Restore d w shortcut in PRs#9262
fregante merged 2 commits into
mainfrom
one-click-options

Conversation

@fregante

Copy link
Copy Markdown
Member

Test URLs

Shortcut only:

Button:

Tab

Screenshot 15

No tab

Screenshot 14

Disable style (unchanged)

Screenshot 16

@github-actions github-actions Bot added the bug label Apr 25, 2026
@fregante

Copy link
Copy Markdown
Member Author

function isHidingWhitespace(): boolean {
// The selector is the native button
return new URL(location.href).searchParams.get('w') === '1'
|| elementExists('button[name="w"][value="0"]:not([hidden])');

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GitHub no longer preserves the setting across loads. If the page doesn't have ?w=1 then whitespace changes are visible.

There's a minor "issue" where if you are on pull/123/changes?w=1 and click the "Files changed" tab, GitHub will remove the URL parameter. The page is not reloaded, so it doesn't really affect us since isHidingWhitespace already ran

);
}

function attachPrButtons(dropdown: HTMLDetailsElement): void {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Buttons dropped from PR because the native popup is now fast enough:

Image

Back then it would require an additional click to "save" the options change. Now it doesn't even require a page load for the layout switch.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the native popup is now fast enough

As someone who often switches between unified and split views, I disagree

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keyboard shortcut time?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is my unfinished commit that restores the feature: SunsetTechuila@21ebe55

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the problem with having open/unfinished work for months, it blocks others from working on issues

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it has substantial changes and we can drop the GHE version, I'd say I can merge this PR (since it does restore d w) and then you can take your time restoring the buttons cleanly on the new PR view

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

const anchor = nativeDiffButtons.parentElement!;

// `usesFloats` is necessary to ensure the order and spacing as seen in #5958
const usesFloats = anchor?.classList.contains('float-right');

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

usesFloats is now always true, so I dropped the condition

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2022 me: "Can be dropped in 3 months" without leaving a comment 😅

@fregante fregante changed the title one-click-diff-options - Restore shortcut in PRs one-click-diff-options - Restore d w shortcut in PRs Apr 25, 2026
@fregante fregante merged commit e44fa65 into main Apr 25, 2026
13 checks passed
@fregante fregante deleted the one-click-options branch April 25, 2026 09:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

one-click-diff-options broken

2 participants