Although the text must be empty for the mode to change to plain text
mode, there still may be a non-default style for the temporary insert
style and style for the end of text run.
There are unsupported flags documented on MSDN which would cause problems
for the equality checks used in EM_SETCHARFORMAT. Also, to handle a
combined set of flags they must be checked for in the right order.
ME_InsertTextFromCursor could previously follow the ME_CommitUndo call
leaving uncommitted changes which would cause improper grouping of commits,
or an assertion failure.
Revert commit 049cf5aca0
richedit: Avoid notifying parent window in improper state.
The commit was meant to fix a problem caused by ME_SendSelChange being
called in ME_SendSelChange, but moving the calls to ME_CommitUndo caused
a regression. So this patch reverts the previous commit, and my
following patch will instead fix the bug by moving the call to
ME_SendSelChange out of ME_CommitUndo.
ME_CommitUndo and ME_CommitCoalescingUndo call ME_SendSelChange, which
may notify the parent window that the selection has changed, therefore
should generally be called after wrapping the text. Otherwise, the parent
window may send a message to the editor and cause an assertion failure.
The parent window for the richedit control on creation is the one that
receives notify messages, even after the parent has been changed using
SetParent.
Using the ITextHost interface allows this notification to be received
for windowless richedit controls. Windowed richedit conrols have an
ITextHost implementation that will fill in hwndFrom and idFrom, but
these should probably be initialized to 0 for windowless richedit
controls.
The test that succeeded from this change was as a result of allowing the
end of the character format change be specified using NULL as the rest
of the text. Before, the end paragraph run at the end of the text was
not being set for this case, when all the text was supposed to have its
character format changed.
Plenty of places in the code find following or preceding runs, then
afterwards find the paragraph from the run. This is inefficient because
the same linked list is used for both runs and paragraphs, so changes in
paragraphs can be detected while returning the next or previous run.
The code was previously getting the same text in the loop from the
editor, and it was converting each of the prefixes to compare against
for each URL candidate.