Skip to content

Test: variable line heights #246822

Closed
Closed

Description

Refs: #147067

Complexity: 5

Create Issue

Create Issue


This iteration it has been made possible to define variable line heights in the the editor through editor decorations which override the default line height. There is a new property in the monaco.d.ts file called lineHeight in the IModelDecorationOptions which can be used to specify the line height for a specific range. The goal of this TPI is to verify that user interactions with editor lines having non-default line heights remain correct and to file issues otherwise. Some points to note are as follows:

  • To simplify the code we have made the line height be applied only to the first line of the range of a decoration, not to the full range. This needs to be revised in the future.
  • We have not yet surfaced the decoration lineHeight property in the vscode.d.ts for extensions to use. Please see below for how to define this property in an extension.
  • The line height for a specific line is defined by the maximum of the decorations line heights set on the given line
  • The line heights are set per-editor, not per model
  • This TPI only concerns variable line heights, not variable font-sizes and font-families, which I am currently working on.

Preparing the test

To test, the easiest to do is to start from the following PR: #246827. This PR surfaces the line height as a configurable property in the vscode.d.ts file and sets up the relevant code to convert the extension host decoration line height to the monaco editor line height. The PR also adds code to the inbuilt TypeScript extension so that lines that have class and interface names have line height 100, lines that have function signatures have line height 70 and lines that have method signatures have line height 30. If you run the code from the PR you should see something similar to the following:

Image

Alternatively to test, you can add the change from the vscode.d.ts and the extHostTypeConverter.ts files from the PR above into the clean VS Code repo, run this new code and in OSS run a new extension which defines variable line heights.

I also invite you to find existing inbuilt monaco editors in VS Code (like for example the panel chat code blocks), set variable line heights on them, and test these cases!

Testing

The goal of this TPI is to break the user interaction with the editor when variable line heights are set on the editor. Think of settings and user actions that involve the editor line heights and which could break the variable line heights rendering. The following is a list of points I have already tested, but could serve as examples for other things to look out for:

  • The lines are rendered correctly, not on top of each other, as you scroll or move the cursor
  • The cursor extends over the whole active line and is correctly positioned vertically and horizontally
  • Line is rendered correctly when two decorations setting line heights intersect
  • Lines with variables heights are rendered correctly and without visible glitch/large on large files
  • Ghost-text and whitespaces are rendered correctly and are aligned with the text in the variable line heights
  • Codelens are positioned correctly above the variable line height as expected
  • Selection backgrounds extend over the whole line height as expected
  • Menu is correctly positioned
  • Editor hover is correctly positioned above the given line
  • IME is correctly positioned below line height
  • Screen reader box is correctly positioned on variable line height
  • Editor sticky scroll is correctly rendered
  • Enable word wrap and resize the editor, make sure the line heights are rendered correctly

It would not hurt to test further the points above, especially if bugs have been introduced in the meantime and if you can push the above cases to their limits and find edge cases.

Known issues

  • If the model of an editor with variable line heights is changed, then viewed with a diff editor, it may be that the left diff editor has no variable line heights while the right diff editor does. This would lead to diff editor lines not being aligned.
  • When you have editor sticky scroll enabled, when you jump to a reference, the cursor may end up under the sticky scroll widget. This is happening because we show maximumNumberOfStickyLines*lineHeight pixels above the cursor position when it jumps. This used to work when all the lines had the same height which is not the case anymore.

Thanks for testing!

Activity

  1. changed the title [-]TPI: Variable line heights[/-] [+]Test: variable line heights[/+] on Apr 17, 2025
  2. bpasero commented on Apr 28, 2025

    @bpasero
    Contributor

    This is very cool 👏

  3. anthonykim1 commented on Apr 28, 2025

    @anthonykim1
    Contributor

    I love this feature, much easier to read files that are crammed/packed!

  4. removed their assignment
    on Apr 28, 2025
  5. TylerLeonhardt commented on Apr 28, 2025

    @TylerLeonhardt
    Member

    Pretty cool! I added on to your sample in another branch that adds Markdown support:
    intact-lemming...tyler/smiling-krill

    Image

  6. locked and limited conversation to collaborators on Jun 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions