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
{{ message }}
This repository was archived by the owner on Apr 16, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Apr 16, 2026. It is now read-only.
[core] Document (and/or create new) API for gutter sizing #5834
It's not currently documented how to create gutters that dynamically change their width, or whether it's not possible to do well and you'd instead recommend e.g. to achieve this effect by adding/removing fixed-size gutters. We've been working around this in some kinda-hacky ways, but we're running into some scaling limitations with our current approaches. And we see that resizing is handled well for e.g. the case of the line number gutter, so my hope is that the technique used there can be opened up for API use.
The line number gutter is treated as a special case in the code, and resizing for other gutters is indeed not currently possible (short of changing their style though manipulating CSS or parent selectors and then calling .refesh()). What does your current hack look like?
It looks like we basically try to keep all of our gutter markers of ours in a single gutter (which we display along with the line numbers and fold markers), and then fetch the element with that class name and reset its .style.width on the CM 'changes' event and when we otherwise need to add/remove different visible markers. We also try to optimize things and not change the property when it's already as it should be, and when the editor is not visible. The main issue we run into is that sometimes CM will redraw the gutters (which wipes out our custom width), and AFAICT there's no event emitted when this happens. So the quick fix would be to emit some kind of event when this happens, so we can reset the correct widths on our gutters and .refresh().
So the quick fix would be to emit some kind of event when this happens
That'd be pretty kludgey though—the editor assumes it is in charge of drawing the gutters, and scripts that jump in an mutate them are not really the way this API works.
So I went ahead and added a feature where you can specify a gutter with a {className, style} pair instead of just a class name string in c18094e, so that you can use the gutters option to dynamically specify a width for your gutters. Does that work for you?
Activity
marijnh commentedon Mar 26, 2019
The line number gutter is treated as a special case in the code, and resizing for other gutters is indeed not currently possible (short of changing their style though manipulating CSS or parent selectors and then calling
.refesh()). What does your current hack look like?mtaran-google commentedon Mar 27, 2019
It looks like we basically try to keep all of our gutter markers of ours in a single gutter (which we display along with the line numbers and fold markers), and then fetch the element with that class name and reset its .style.width on the CM 'changes' event and when we otherwise need to add/remove different visible markers. We also try to optimize things and not change the property when it's already as it should be, and when the editor is not visible. The main issue we run into is that sometimes CM will redraw the gutters (which wipes out our custom width), and AFAICT there's no event emitted when this happens. So the quick fix would be to emit some kind of event when this happens, so we can reset the correct widths on our gutters and .refresh().
Allow CSS styles to be passed for gutter backgrounds
marijnh commentedon Mar 28, 2019
That'd be pretty kludgey though—the editor assumes it is in charge of drawing the gutters, and scripts that jump in an mutate them are not really the way this API works.
So I went ahead and added a feature where you can specify a gutter with a
{className, style}pair instead of just a class name string in c18094e, so that you can use theguttersoption to dynamically specify a width for your gutters. Does that work for you?mtaran-google commentedon Apr 1, 2019
It looks like that should work for us. Thank you! :)
Allow CSS styles to be passed for gutter backgrounds
Update from master (#1)