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.

Problem with wordwrap in nested CodeMirror #2420

@njx

Description

@njx

In Brackets, to implement our "inline editor" feature, we create line widgets that contain nested CodeMirror instances. The nested CMs are height: auto, and we automatically set the size of the containing line widget to match the height of the nested CM, e.g. if the wrapping changes. This used to work fine, but has a bug in CMv4.

Here's a standalone repro case:

  1. If on Mac, in System Preferences > General set "Show scroll bars:" to "Always" (or use a mouse); on Windows, this shouldn't be necessary
  2. Open https://gist.github.com/njx/9905035 in Chrome
  3. Resize the window a bit to get the line widget to appear (not sure why this is necessary)
  4. Double-click on "background" in the line widget to select it
  5. Resize the window narrower until the "font-family" line starts to wrap
  6. Slowly resize the window wider just past the point where the "font-family line" should no longer wrap

Result:

  • The text at the end flickers between wrapping and not wrapping.
  • The selection below the wrapped text jumps around between lines as you resize.

It seems as though CM's idea of what text is wrapped is different from the browser's own line wrapping.

This problem seems to have been introduced by 2007b3c.

Also note that on Mac it only reproduces if scrollbars are always visible, so it's probably somehow related to the layout of the fake scrollbar somehow (though in this case the scrollbar should never be visible because the widget is always sized to the content height, it could be that there's some timing problem where the scrollbar is briefly visible).

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