You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Very tall code blocks make the thread hard to follow and requires a lot of scrolling. Ideally, users should just post a Gist link, but they don't. Instead, we could limit the height and make it scrollable.
To determine whats a tall piece of code, I was thinking maybe using the clientHeight of the pre or blockquote element and if the height is greater than (X) we can make it scrollable
I am not sure what you mean by clipping in the middle of a line? Do you want me to set a default position of scrollbar to middle so the users can see the scroll bar?
import'webext-dynamic-content-scripts';importonAjaxedPagesfrom'github-injection';importselectfrom'select-dom';importdomLoadedfrom'dom-loaded';importmarkUnreadfrom'./features/mark-unread';importaddOpenAllNotificationsButtonfrom'./features/open-all-notifications';importaddUploadBtnfrom'./features/upload-button';importenableCopyOnYfrom'./features/copy-on-y';importaddReactionParticipantsfrom'./features/reactions-avatars';importshowRealNamesfrom'./features/show-names';importaddCopyFilePathToPRsfrom'./features/copy-file-path';importaddFileCopyButtonfrom'./features/copy-file';// - import copyMarkdown from './features/copy-markdown';importlinkifyCodefrom'./features/linkify-urls-in-code';importautoLoadMoreNewsfrom'./features/auto-load-more-news';importaddOPLabelsfrom'./features/op-labels';importaddMoreDropdownfrom'./features/more-dropdown';importaddReleasesTabfrom'./features/add-releases-tab';importaddGistsLinkfrom'./features/add-gists-link-to-profile';importaddTimeMachineLinksToCommentsfrom'./features/add-time-machine-links-to-comments';importremoveUploadFilesButtonfrom'./features/remove-upload-files-button';importscrollToTopOnCollapsefrom'./features/scroll-to-top-on-collapse';importremoveDiffSignsfrom'./features/remove-diff-signs';importlinkifyBranchRefsfrom'./features/linkify-branch-refs';importhideEmptyMetafrom'./features/hide-empty-meta';importhideOwnStarsfrom'./features/hide-own-stars';importmoveMarketplaceLinkToProfileDropdownfrom'./features/move-marketplace-link-to-profile-dropdown';importaddYourRepoLinkToProfileDropdownfrom'./features/add-your-repositories-link-to-profile-dropdown';importaddTrendingMenuItemfrom'./features/add-trending-menu-item';importaddProfileHotkeyfrom'./features/add-profile-hotkey';importaddYoursMenuItemfrom'./features/add-yours-menu-item';importaddCommentedMenuItemfrom'./features/add-commented-menu-item';importaddToggleFilesButtonfrom'./features/add-toggle-files-button';importaddReadmeButtonsfrom'./features/add-readme-buttons';importaddBranchButtonsfrom'./features/add-branch-buttons';importaddDeleteForkLinkfrom'./features/add-delete-fork-link';importlinkifyIssuesInTitlesfrom'./features/linkify-issues-in-titles';importaddPatchDiffLinksfrom'./features/add-patch-diff-links';importmarkMergeCommitsInListfrom'./features/mark-merge-commits-in-list';importshowRecentlyPushedBranchesfrom'./features/show-recently-pushed-branches';importaddDiffViewWithoutWhitespaceOptionfrom'./features/add-diff-view-without-whitespace-option';importpreserveWhitespaceOptionInNavfrom'./features/preserve-whitespace-option-in-nav';importaddMilestoneNavigationfrom'./features/add-milestone-navigation';importaddFilterCommentsByYoufrom'./features/add-filter-comments-by-you';importremoveProjectsTabfrom'./features/remove-projects-tab';importfixSquashAndMergeTitlefrom'./features/fix-squash-and-merge-title';importaddTitleToEmojisfrom'./features/add-title-to-emojis';importsortMilestonesByClosestDueDatefrom'./features/sort-milestones-by-closest-due-date';importmoveAccountSwitcherToSidebarfrom'./features/move-account-switcher-to-sidebar';importopenCIDetailsInNewTabfrom'./features/open-ci-details-in-new-tab';importfocusConfirmationButtonsfrom'./features/focus-confirmation-buttons';importaddKeyboardShortcutsToCommentFieldsfrom'./features/add-keyboard-shortcuts-to-comment-fields';importaddConfirmationToCommentCancellationfrom'./features/add-confirmation-to-comment-cancellation';importaddCILinkfrom'./features/add-ci-link';importembedGistInlinefrom'./features/embed-gist-inline';importextendIssueStatusLabelfrom'./features/extend-issue-status-label';importhighlightClosingPrsInOpenIssuesfrom'./features/highlight-closing-prs-in-open-issues';importtoggleAllThingsWithAltfrom'./features/toggle-all-things-with-alt';importaddJumpToBottomLinkfrom'./features/add-jump-to-bottom-link';importaddQuickReviewButtonsfrom'./features/add-quick-review-buttons';importextendDiffExpanderfrom'./features/extend-diff-expander';importsortIssuesByUpdateTimefrom'./features/sort-issues-by-update-time';importmakeDiscussionSidebarStickyfrom'./features/make-discussion-sidebar-sticky';importshortenLinksfrom'./features/shorten-links';importwaitForBuildfrom'./features/wait-for-build';importaddDownloadFolderButtonfrom'./features/add-download-folder-button';importhideUselessNewsfeedEventsfrom'./features/hide-useless-newsfeed-events';importcloseOutOfViewModalsfrom'./features/close-out-of-view-modals';importaddScopedSearchOnUserProfilefrom'./features/add-scoped-search-on-user-profile';importmonospaceTextareasfrom'./features/monospace-textareas';importimproveShortcutHelpfrom'./features/improve-shortcut-help';import*aspageDetectfrom'./libs/page-detect';import{safeElementReady,enableFeature}from'./libs/utils';importobserveElfrom'./libs/simplified-element-observer';// Add globals for easier debuggingwindow.select=select;asyncfunctioninit(){awaitsafeElementReady('body');if(pageDetect.is404()||pageDetect.is500()){return;}if(document.body.classList.contains('logged-out')){console.warn('%cRefined GitHub%c only works when you’re logged in to GitHub.','font-weight: bold','');return;}if(select.exists('html.refined-github')){console.warn('Refined GitHub has been loaded twice. If you didn’t install the developer version, this may be a bug. Please report it to: https://github.com/sindresorhus/refined-github/issues/565');return;}document.documentElement.classList.add('refined-github');if(!pageDetect.isGist()){enableFeature(addTrendingMenuItem);}if(pageDetect.isDashboard()){enableFeature(moveAccountSwitcherToSidebar);enableFeature(hideUselessNewsfeedEvents);}if(pageDetect.isRepo()){onAjaxedPages(async()=>{// Wait for the tab bar to be loadedawaitsafeElementReady('.pagehead + *');enableFeature(addMoreDropdown);enableFeature(addReleasesTab);enableFeature(removeProjectsTab);});}if(pageDetect.isUserProfile()){enableFeature(addScopedSearchOnUserProfile);}enableFeature(focusConfirmationButtons);enableFeature(addKeyboardShortcutsToCommentFields);enableFeature(addConfirmationToCommentCancellation);enableFeature(monospaceTextareas);// TODO: Enable this when we've improved how copying Markdown works// See #522// delegate('.markdown-body', 'copy', copyMarkdown);awaitdomLoaded;onDomReady();}functiononDomReady(){enableFeature(markUnread);enableFeature(addOpenAllNotificationsButton);enableFeature(enableCopyOnY);enableFeature(addProfileHotkey);enableFeature(makeDiscussionSidebarSticky);enableFeature(closeOutOfViewModals);enableFeature(improveShortcutHelp);if(!pageDetect.isGist()){enableFeature(moveMarketplaceLinkToProfileDropdown);enableFeature(addYourRepoLinkToProfileDropdown);}if(pageDetect.isGist()){enableFeature(addFileCopyButton);}if(pageDetect.isDashboard()){enableFeature(hideOwnStars);enableFeature(autoLoadMoreNews);}onAjaxedPages(ajaxedPagesHandler);}functionajaxedPagesHandler(){enableFeature(hideEmptyMeta);enableFeature(removeUploadFilesButton);enableFeature(addTitleToEmojis);enableFeature(shortenLinks);enableFeature(linkifyCode);enableFeature(addDownloadFolderButton);enableFeature(linkifyBranchRefs);if(pageDetect.isIssueSearch()||pageDetect.isPRSearch()){enableFeature(addYoursMenuItem);enableFeature(addCommentedMenuItem);}enableFeature(sortIssuesByUpdateTime);// Must be after addYoursMenuItem + addCommentedMenuItemif(pageDetect.isMilestone()){enableFeature(addMilestoneNavigation);// Needs to be before sortMilestonesByClosestDueDate}if(pageDetect.isRepo()){enableFeature(addReadmeButtons);enableFeature(addBranchButtons);enableFeature(addDiffViewWithoutWhitespaceOption);enableFeature(removeDiffSigns);enableFeature(addCILink);enableFeature(sortMilestonesByClosestDueDate);// Needs to be after addMilestoneNavigation}if(pageDetect.isRepoRoot()){enableFeature(addToggleFilesButton);}if(pageDetect.isPR()){enableFeature(scrollToTopOnCollapse);enableFeature(addDeleteForkLink);enableFeature(fixSquashAndMergeTitle);enableFeature(openCIDetailsInNewTab);enableFeature(waitForBuild);enableFeature(toggleAllThingsWithAlt);}if(pageDetect.isPR()||pageDetect.isIssue()){enableFeature(linkifyIssuesInTitles);enableFeature(addUploadBtn);enableFeature(embedGistInline);enableFeature(extendIssueStatusLabel);enableFeature(highlightClosingPrsInOpenIssues);observeEl('.new-discussion-timeline',()=>{enableFeature(addOPLabels);enableFeature(addTimeMachineLinksToComments);});}if(pageDetect.isNewIssue()){enableFeature(addUploadBtn);}if(pageDetect.isIssue()||pageDetect.isPRConversation()){enableFeature(addJumpToBottomLink);}if(pageDetect.isPRList()||pageDetect.isIssueList()){enableFeature(addFilterCommentsByYou);}if(pageDetect.isPRList()||pageDetect.isIssueList()||pageDetect.isPR()||pageDetect.isIssue()){enableFeature(showRecentlyPushedBranches);}if(pageDetect.isCommit()){enableFeature(addPatchDiffLinks);enableFeature(toggleAllThingsWithAlt);}if(pageDetect.isCompare()){enableFeature(toggleAllThingsWithAlt);}if(pageDetect.isPR()||pageDetect.isIssue()||pageDetect.isCommit()||pageDetect.isDiscussion()){enableFeature(addReactionParticipants);enableFeature(showRealNames);}if(pageDetect.isCommitList()){enableFeature(markMergeCommitsInList);}if(pageDetect.isPRFiles()||pageDetect.isPRCommit()){enableFeature(addCopyFilePathToPRs);enableFeature(preserveWhitespaceOptionInNav);}if(pageDetect.isPRFiles()){enableFeature(addQuickReviewButtons);enableFeature(extendDiffExpander);}if(pageDetect.isSingleFile()){enableFeature(addFileCopyButton);}if(pageDetect.isUserProfile()){enableFeature(addGistsLink);}}init();
For people's reference → to disable this feature, add this to the extension's custom css:
.comment-body blockquote,
.comment-body pre {
max-height: none;
}
Reacted by fregante, Ahmed El Gabri, Sergei Sergeev, Dominic Scheirlinck, Dorian Marchal, Niko Eckerskorn, 青いほしぞら, Stephen Halter, Marek Lewandowski, haxscramper and 1 more
Activity
yakov116 commentedon Feb 28, 2018
@sindresorhus thats a quote
>not ``fregante commentedon Feb 28, 2018
Perhaps both
blockquotes andpreshould be scrollablesindresorhus commentedon Feb 28, 2018
Yes
rooneyg21 commentedon Feb 28, 2018
To determine whats a tall piece of code, I was thinking maybe using the clientHeight of the pre or blockquote element and if the height is greater than (X) we can make it scrollable
fregante commentedon Feb 28, 2018
No need, we can just add a
max-heightandoverflow: autovia CSSrooneyg21 commentedon Feb 28, 2018
what do yo guys think is a good number for the max-height?
I tested 30em and it looks good. I think it is big enough for small code snippets as well.
fregante commentedon Mar 5, 2018
Just make sure that it clips in the middle of a line, so the clipping is more noticeable.
rooneyg21 commentedon Mar 5, 2018
I am not sure what you mean by clipping in the middle of a line? Do you want me to set a default position of scrollbar to middle so the users can see the scroll bar?
1 remaining item
sindresorhus commentedon Mar 17, 2018
Testing:
fregante commentedon Jun 28, 2018
dwelle commentedon Mar 23, 2019
For people's reference → to disable this feature, add this to the extension's custom css:
dorian-marchal commentedon Jul 22, 2019
Thanks, it would be nice to have an option flag for this. 👍
mohe2015 commentedon Jul 22, 2019
@dorian-marchal I think you can now disable all features in the settings. Just look into the list for the feature and uncheck the checkbox.
yakov116 commentedon Jul 22, 2019
@mohe2015 this one is only via the CSS option
chrisblossom commentedon Oct 30, 2019
I found this issue trying to disable this again (settings keep getting reset somehow).
#1146 (comment)
ajtruckle commentedon Jun 22, 2024
Sorry, but it is not clear to me. How can I make long code blocks scrollable? Much like StackOverflow?
fregante commentedon Jun 22, 2024
I don't know what you're referring to exactly, but this repo is for a Chrome extension: https://github.com/refined-github/refined-github
Unless you want to make the code scrollable *here on GitHub, you might want to ask the question on StackOverflow.