-
Notifications
You must be signed in to change notification settings - Fork 654
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
Codemirror tabs #959
base: master
Are you sure you want to change the base?
Codemirror tabs #959
Conversation
2,4,8 covers 99.9% use cases. |
This reminds me of something I read, it said. All statistics on the web are made up on the spot =) hahaha |
Should we remove/hide Also about tab/vs spaces, can we cover that in style also, because adding this will make those GH settings not work so no point showing elements that a user is gonna fiddle with and have no effect. IDK whats best, I dont like opinionated things as default but in this case ... |
98f96ae
to
793fb7a
Compare
f5090f7
to
c4c63b4
Compare
Rebased on master to check and no dice, even the default tabs settings in GitHub are broken anyway. |
Can @StylishThemes/github please check that without GitHub Dark the tab settings while editing a file via browser, dont work. Im expecting the tab to change in existing lines this doesnt work. With GitHub Dark the existing tab settings in usercss stylus side also dont work for this anymore either and these changes also dont work either. |
@the-j0k3r those settings don't change what's already in the editor, they're for when you're writing new code. If you change to tabs that are 8 spaces wide and then add a new line to the file you should see it indented with a single tab equal to 8 spaces. That's how it works for me with and without GitHub Dark. The tab size in the preview is also working, but there doesn't seem to be a difference between 2 and 4 for me. Switching from 4 to 8 works though. |
See #543 (comment) thats how its supposed to work The indenting for new code makes no sense without changing the indenting of existing code, thats how it used to work now with new behavior its IMO broken. |
It looks like the spacing in the editor does change on existing code but only if you're using tabs. Since all our files use spaces it's not going to resize them. |
Again its buggy because you have the option to select tab type. That should also matter. Its just me then =) |
/* ==UserStyle==
@name GitHub Tabs
@namespace Tabs for GitHub
@version 1.0.0
@description A customizable tab width style for GitHub
@version 0.0.1
@author the-j0k3r (c) 2021
@license No Redistribution
@preprocessor stylus
@var number tab_size 'Tab size ' [8, 2, 8, 1]
==/UserStyle== */
// helpers
i = !important
@-moz-document domain("github.com") {
// defaults to 8 which is GH default
pre, .highlight, .diff-table, .tab-size {
tab-size: tab_size i
-moz-tab-size: tab_size i
}
.cm-tab {
width: tab_size ch i
}
// Hide tab width select from CodeMirror when editing files via browser
// https://github.com/StylishThemes/GitHub-Dark/pull/959#issuecomment-504646695
if (tab_size) {
select[id="indent-size"] {
display: none i
}
}
} If people dont want to wait for this PR heres something I knocked up for my own GH style to essentially do the same as this PR should replace the options in GitHub Dark, i.e. dont use those when using this. @Mottie with ❤️ |
In case anyone else was going crazy about this, the recommended snippet above didn't seem to work for me in diff mode (width was ~halved from what I expected), but does in other modes. I finally figured out this was a way to fix it for diffs: /*....
@var number tab_size 'Tab size ' [8, 2, 8, 1, 'ch']
==/UserStyle== */ I'm not sure why, I guess the default unit has a different size than |
@ian-h-chamberlain, can you post a link to this page place way to reproduce? Im interested because you added unit values and that value may have a knock on effect in other places. Not the least .cm-tab already had that value appended and now it will likely break. |
@the-j0k3r I noticed after I posted that comment, this is one example (most golang repos use tabs instead of spaces): Note, I use the split diff view in the gear dropdown on that page. No units (except With It still seems slightly off, which is weird since |
Well be aware the other not cm-tabs selectors may not work anymore as intended. I will have a look at it later. |
Im looking here https://github.com/bivious/k-plus/blob/master/src/modules/dcc/DccFileTransfer.h and 8ch is always wider than just 8, so no idea. |
1ch is relative to the width of the "0" (zero), so I wonder if font size will affect that. while the integer is a multiple of the advance width of the space character (U+0020) to be used as the width of tabs. (Character 'SPACE' is 0020) so ch is really not really a reliable if its relative to the width of 0 and depending on the font user has and size will determine the end result. So need to find an immutable unit that is fixed width no matter the font size. Else ignore the differences. |
Yeah, this is the part that confused me – since I am using a monospace font, I would expect U+0020 and For posterity, this is the full style I am now using, and it seems to work well enough for my purposes – but maybe others people's preferences would be different. /* ==UserStyle==
@name GitHub Tabs
@namespace Tabs for GitHub
@version 1.0.0
@description A customizable tab width style for GitHub
@author the-j0k3r (c) 2021
@license No Redistribution
@preprocessor stylus
@var number tab_size "Tab size" [8, 2, 8, 1, "ch"]
default, min, max, step, units
==/UserStyle== */
@-moz-document domain("github.com") {
// defaults to 8 which is GH default
pre, .highlight, .diff-table, .tab-size {
tab-size: tab_size !important;
-moz-tab-size: tab_size !important;
}
.cm-tab {
width: tab_size !important;
}
// Hide tab width select from CodeMirror when editing files via browser
// https://github.com/StylishThemes/GitHub-Dark/pull/959#issuecomment-504646695
if (tab_size) {
select[id="indent-size"] {
display: none !important;
}
}
} |
The font in use doesn't matter, because a 14/16/other px sizes will affect the width of 0 more than the width of space. Stackoveflows as some things to say about this https://stackoverflow.com/questions/24970502/what-is-the-width-of-empty-space-in-html It doesn't mention a comparison between width of 0/space, but I'm confident that ch is a better choice in this case. FYI n my GitHub style I am using ch same way you have altered the style, since I no longer use GHD or the standalone snippet above, however I will experiment with absolute lengths rather than relative see https://www.w3schools.com/CSSref/css_units.asp |
From a quick experiment, it seems like |
Possible fix for #543.
Test it with this gist I set up: https://gist.github.com/Mottie/d40ab58bb68cbeb2c314237189051b77/edit