Bug 118629: Set the caret hint when inserting text so that the caret appears on the same line as inserted text not ending with a newline, and on the line following text ending with a newline. Patch by Uri Bernstein <uriber@gmail.com>, r+sr=roc

git-svn-id: svn://10.0.0.236/trunk@181706 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
smontagu%smontagu.org 2005-10-06 08:19:51 +00:00
parent d7f97ff76a
commit 5ee547497a

View File

@ -399,9 +399,6 @@ nsTextEditRules::WillInsert(nsISelection *aSelection, PRBool *aCancel)
nsresult
nsTextEditRules::DidInsert(nsISelection *aSelection, nsresult aResult)
{
// Attach to the frame now before the caret
nsCOMPtr<nsISelectionPrivate>selPrivate(do_QueryInterface(aSelection));
selPrivate->SetInterlinePosition(PR_FALSE);
return NS_OK;
}
@ -779,7 +776,15 @@ nsTextEditRules::WillInsertText(PRInt32 aAction,
outString->Assign(tString);
if (curNode)
{
aSelection->Collapse(curNode, curOffset);
// Make the caret attach to the inserted text, unless this text ends with a LF,
// in which case make the caret attach to the next line.
PRBool endsWithLF = !tString.IsEmpty() && tString.get()[tString.Length() - 1] == nsCRT::LF;
nsCOMPtr<nsISelectionPrivate>selPrivate(do_QueryInterface(aSelection));
selPrivate->SetInterlinePosition(endsWithLF);
}
}
return res;
}