Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug in selection handling in dom renderer #4681

Merged
merged 1 commit into from
Aug 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/browser/renderer/dom/DomRendererRowFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,11 @@ export class DomRendererRowFactory {
cellAmount
&& (
(isInSelection && oldIsInSelection)
|| (!isInSelection && cell.bg === oldBg)
|| (!isInSelection && !oldIsInSelection && cell.bg === oldBg)
)
&& (
(isInSelection && oldIsInSelection && colors.selectionForeground)
|| (!(isInSelection && oldIsInSelection && colors.selectionForeground) && cell.fg === oldFg)
|| cell.fg === oldFg
)
Comment on lines 167 to 174
Copy link
Member

@jerch jerch Aug 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion - for the sake of readability lets separate concerns here:

  // selection state must not change
  && isInSelection === oldIsInSelection
  // outside of selections BG must match
  && (!isInSelection && cell.bg === oldBg)
  // default FG must match
  // exception: in selections selectionForeground may override FG
  && (cell.fg === oldFg || (isInSelection && colors.selectionForeground))

To me thats much easier to grasp than deep nested conditions, hopefully I covered all cases 😸.

The FG rule is still nested, at least it pulls the more likely case to the left, which should result in faster processing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That re-write seems to work fine my testing. And I'm inclined to agree it is cleaner. I was aiming for a minimal fix, but I'm happy also doing minor logic simplification.

&& cell.extended.ext === oldExt
&& isLinkHover === oldLinkHover
Expand Down