Skip to content

Commit

Permalink
Use contains_escaped_quote
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh committed Nov 13, 2023
1 parent 4648350 commit be9cf4e
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ pub(crate) fn avoidable_escaped_quote(
continue;
}

if string_contents.contains(quotes_settings.inline_quotes.as_char())
if contains_escaped_quote(&string_contents, quotes_settings.inline_quotes.as_char())
&& !string_contents.contains(quotes_settings.inline_quotes.opposite().as_char())
{
let mut diagnostic = Diagnostic::new(AvoidableEscapedQuote, tok_range);
Expand All @@ -207,9 +207,8 @@ pub(crate) fn avoidable_escaped_quote(
let text = locator.slice(tok_range);
// Check for escaped quote only if we're using the preferred quotation
// style and it isn't a triple-quoted f-string.
let check_for_escaped_quote = text
.contains(quotes_settings.inline_quotes.as_char())
&& !is_triple_quote(text);
let check_for_escaped_quote = !is_triple_quote(text)
&& text.contains(quotes_settings.inline_quotes.as_char());
fstrings.push(FStringContext::new(
check_for_escaped_quote,
tok_range,
Expand All @@ -232,7 +231,8 @@ pub(crate) fn avoidable_escaped_quote(
context.ignore_escaped_quotes();
continue;
}
if string_contents.contains(quotes_settings.inline_quotes.as_char()) {
if contains_escaped_quote(string_contents, quotes_settings.inline_quotes.as_char())
{
context.push_fstring_middle_range(tok_range);
}
}
Expand Down

0 comments on commit be9cf4e

Please sign in to comment.