Sanket and strings

i dont understand the following segment of the code provided in the editorial,

    //Move left pointer by one to slide the window
    i++;

    //If the char at previous position of left pointer was not ch, then that position must
    //have counted as a swap earlier. Now we have a free swap available.
    //Iterate right pointer forward to use that one free swap
    if (j < s.size() - 1 && s[i - 1] != ch)
    {
        j++;
    }
}

In this segment of the code there are two parts
First part is to move the left edge of the window by one, this one is straightforward

Now the second part is that the character at ith position before the first part (currently i-1 as we moved i one step forward) is not ch, then that means that it was swapped.
Now since swap occurs in pairs (swapping x and y means changing the value of both x and y to the value of y and x), to complete the swap we need to change one more value at the j side.
This is being done in the second part of the code segment.