142826: move to beginning of found pattern after a reverse find. Fix is from harry.lu@sun.com, r=me, sr=sfraser, a=asa
This commit is contained in:
Родитель
ee7c06ca9c
Коммит
74da9b4ffe
|
@ -210,6 +210,15 @@ function onReplace()
|
|||
// Transfer dialog contents to the find service.
|
||||
saveFindData();
|
||||
|
||||
// For reverse finds, need to remember the caret position
|
||||
// before current selection
|
||||
var newRange;
|
||||
if (gReplaceDialog.searchBackwards.checked && selection.rangeCount > 0)
|
||||
{
|
||||
newRange = selection.getRangeAt(0).cloneRange();
|
||||
newRange.collapse(true);
|
||||
}
|
||||
|
||||
// nsPlaintextEditor::InsertText fails if the string is empty,
|
||||
// so make that a special case:
|
||||
var replStr = gReplaceDialog.replaceInput.value;
|
||||
|
@ -218,6 +227,13 @@ function onReplace()
|
|||
else
|
||||
gEditor.insertText(replStr);
|
||||
|
||||
// For reverse finds, need to move caret just before the replaced text
|
||||
if (gReplaceDialog.searchBackwards.checked && newRange)
|
||||
{
|
||||
gEditor.selection.removeAllRanges();
|
||||
gEditor.selection.addRange(newRange);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче