User:Cobaltcigs/DiffPreviewFindLine

Source code:

With this script enabled, clicking on any of the cells on the right-hand ("your text") side of a preview diff (after clicking the "show changes" button) of a pending edit should locate, select, and scroll to that line in the editing textbox. The intended purpose is to assist manually correcting any mistakes noticed in a script-assisted edit, prior to submitting.

Should be faster than ctrl-C,F,V anyway.

To activate, call this function from your own script sometime after load:

Known limitations:
 * The script uses the line numbers shown in the diff preview and does not attempt to match text by similarity. Any further editing that adds or removes newline characters after the diff page is loaded may invalidate the line numbers and cause the wrong line to be selected. In that case, you'll need to click the "show changes" button again to update the line numbers.
 * Actually matching the text would be tricky to do right because the diff preview evaluates pre-save transforms (e.g. subst, pipe trick, signature tildes).
 * Plus you may have changed the entire line beyond recognition anyway.

One possible improvement (not implemented) would be to monitor every keystroke to see if  has been added or removed (and at what position) and internally offset the line numbers accordingly. But that sounds really complicated...