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

Highlight only last of odd length leading spaces in jest-diff #4558

Merged
merged 1 commit into from
Sep 28, 2017

Conversation

pedrottimark
Copy link
Contributor

Summary

Original goal was to see if text node following element does or doesn’t have a leading space.

What if multiple leading spaces? Oops :(

  • If even number, highlight isn’t needed to see them. For example, indentation in pre element.
  • If odd number, the last seems most important to see. Especially if it’s an indentation error.

Baseline before this PR at left and improved from this PR at right:
2017-09-28 last_odd_leading

By the way, visually unexpected indentation of first line of text because child of pre element.

Caused me to learn more than I wanted to know about regex in replace.

Test plan

Added a snapshot test to specify intended (ha ha, misspelled as indented :) behavior.

Aha, it is possible to use snapshots to fail at first, and then update to improved result.

@codecov-io
Copy link

Codecov Report

Merging #4558 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #4558   +/-   ##
=======================================
  Coverage   56.16%   56.16%           
=======================================
  Files         185      185           
  Lines        6285     6285           
  Branches        3        3           
=======================================
  Hits         3530     3530           
  Misses       2754     2754           
  Partials        1        1
Impacted Files Coverage Δ
packages/jest-diff/src/diff_strings.js 98.83% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1e3ee68...dd5f867. Read the comment docs.

@cpojer
Copy link
Member

cpojer commented Sep 28, 2017

Nice fix!

@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants