Skip to content

--patch can propose a selector the rule above already carries #26

Closed

Description

@adamXbot

--patch emits "confident" replacements, but it rewrites a token in place without looking at the rest of the selector list. When the corrected name is already present on an adjacent line, the result is a duplicate selector.

WhiteSur's private-browsing indicator is the live case. The rule reads:

#TabsToolbar .private-browsing-indicator,
#TabsToolbar .private-browsing-indicator-with-label,
#TabsToolbar #private-browsing-indicator-with-label {
	display: none !important;
}

The id on the third line is genuinely dead — no element carries id="private-browsing-indicator-with-label" in Firefox 153's omni.ja or on ESR 140; it is a class in both. So RENAMED #private-browsing-indicator-with-label → .private-browsing-indicator-with-label is a correct diagnosis, and the patch fxcss writes is:

-#TabsToolbar #private-browsing-indicator-with-label {
+#TabsToolbar .private-browsing-indicator-with-label {

which duplicates the line immediately above it.

Valid CSS and harmless at runtime, so this is a quality-of-output issue rather than a correctness one. It matters because the watch workflow opens a PR from this patch unreviewed — that is the whole point of the "confident fixes" path — so the output is read as what a human would have written. Here a human deletes the line instead, which is what WhiteSurFirefoxThemeMacOS#221 does.

Possible shapes, in rough order of appetite:

  1. When the replacement token already appears elsewhere in the same selector list, drop the dead selector line rather than rewriting it.
  2. Same detection, but leave the finding out of --patch and report it as needing a human, so nothing wrong is ever auto-proposed.
  3. Leave the patch alone and note the duplicate in the finding's reason, so the PR body says why.

(2) is the cheapest and keeps the "confident" bar honest. (1) is what the reader actually wants but means editing selector lists rather than tokens, which is a bigger change than replace_in_line currently makes.

Found while fixing #25; unrelated to it and to #24, so filing separately rather than widening either.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions