Skip to content
This repository was archived by the owner on Apr 16, 2026. It is now read-only.
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

Open

Description

@mtaran-google

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.

Any thoughts/recommendations in this area?

Activity

  1. marijnh commented on Mar 26, 2019

    @marijnh
    Member

    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?

  2. mtaran-google commented on Mar 27, 2019

    @mtaran-google
    ContributorAuthor

    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().

  3. marijnh commented on Mar 28, 2019

    @marijnh
    Member

    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?

  4. mtaran-google commented on Apr 1, 2019

    @mtaran-google
    ContributorAuthor

    It looks like that should work for us. Thank you! :)

  5. added a commit that references this issue on Jan 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions