Skip to content

Bug with template strings in js, ts #911

@artman

Description

@artman

Noticed a diffing problem with template strings in js and ts that peculiarly is changes on whether a newline is present or not

If you have the following original:

const CommentsContainer = styled(Flex)`
  width: 100%;
  margin-top: 16px;

  ${props => props.$withSeparator && 
   `padding-top: 22px;`
  }
`;

and this modified:

const CommentsContainer = styled(Flex)`
  width: 100%;
  margin-top: 16px;
`;

Difftastic won't recognize that the last three lines of the template string have been removed, but will mark the entire template string as changed.

However, if you just remove one newline in the original before the last closing bracket, difftastic recognizes the deletion correctly:

const CommentsContainer = styled(Flex)`
  width: 100%;
  margin-top: 16px;

  ${props => props.$withSeparator && 
   `padding-top: 22px;`}
`;

The same thing as a CLI screenshot:

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions