Skip to content
This repository was archived by the owner on Mar 3, 2023. It is now read-only.

Improve default decorations for cursor and selection lines in React editor - #2757

Merged
nathansobo merged 14 commits into
masterfrom
ns-better-default-decorations
Jun 28, 2014
Merged

nathansobo merged 14 commits into
masterfrom
ns-better-default-decorations

Conversation

@nathansobo

Copy link
Copy Markdown
Contributor

Fixes #2701

This PR updates the decorations on lines and line numbers in the following way:

  • When the cursor is on a certain line, its line and line number will have the .cursor-line class.
  • When a selection spans lines, their line and line numbers will have the .selection-line class.
  • If the selection is empty, the cursor's line will also contain the .cursor-line-no-selection class. I'd prefer this to be synthesized with .cursor-line:not(.selection-line) but we need it for backward compatibility.

Previously, the .cursor-line class would be applied to every line number in a selection, but now it's only applied to the line containing the cursor for consistency with what we do on line elements. This means certain themes will need to switch .line-number.cursor-line to .line-number.selection-line for the same effect. To support these themes in the old editor, we now also add .selection-line to the line numbers in the gutter.

Here you can see the line highlight working again in the light theme.
screenshot 2014-06-27 05 42 26

@lee-dohm

Copy link
Copy Markdown
Contributor

👏

@nathansobo

Copy link
Copy Markdown
Contributor Author

So after thinking about this more I'm thinking that we shouldn't tie any of these styling changes to the React editor switch. Keeping everything as close as possible to the existing editor will make the transition easier. So I'm going to switch back to the former treatment of cursor-lines for now, and we can revisit this later.

Nathan Sobo added 14 commits June 28, 2014 15:39
It only decorates the head position of the decoration's marker.
The cursor-line decoration shouldn't be applied to every line that's
selected. It should only be applied to the location of the cursor. We'll
need to update themes to reflect this.
The React editor does not apply the .cursor-line-no-selection class,
but instead relies on a combination of .cursor-line and .selection-line
for selectors that want to target the cursor line when there is no
selection.

This allows themes to be upgraded to support the React editor and the
old editor at the same time.
- onlyHead
- onlyEmpty
- onlyNonEmpty
We will introduce .selection-line as part of a separate effort, not the
React switchover.
nathansobo pushed a commit that referenced this pull request Jun 28, 2014
Improve default decorations for cursor and selection lines in React editor
@nathansobo
nathansobo merged commit f5517ba into master Jun 28, 2014
@nathansobo
nathansobo deleted the ns-better-default-decorations branch June 28, 2014 15:04
@probablycorey probablycorey mentioned this pull request Jun 30, 2014
34 of 35 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cursor line highlights don't go full width and show with selections

2 participants