Hi Huw,

diTextEnd is useful for append a '\r' to the last paragraph.
But because of bug of EM_SETSEL or EM_GETSEL, this feature
still cannot be implemented completely.
For example:
When the text in Rich Edit control is: "TestSomeText"
                                                       01234567890123
We cannot distinguish between SendMessageA(w, EM_SETSEL, 0, 12) and SendMessageA(w, EM_SETSEL, 0, 13).
Attachment is the patch, I just added wine_todo for failed tests cause by this bug.
But I still have no idea about fixing this bug. Could you give me some suggestion?
Or just mark them as todo now is OK?

Thank you!


2014-07-07 16:38 GMT+08:00 Huw Davies <huw@codeweavers.com>:
On Fri, Jul 04, 2014 at 07:00:16PM +0800, Jactry Zeng wrote:
> A few weeks ago, I have made some tests about this problem. And it seem is an
> unimplement feature of Rich edit control and should not be fixed in ME_GetTextW
> or ITextSeletction::GetText simply:
>
> 1. end-of-story is different from end-of-paragraph
> From document of ITextDocument::GetStoryCount: Rich edit controls have only one
> story.[1]
> So ‘story’ may is an unit like 'paragraph' in Rich edit control. We may need
> add a MERF_ENDSTORY to implement it.[2]
>
> 2. What does the end-of-story looks like?
> When we run the wordpad with native riched20, we can use ‘ctrl + shitf + →’ to
> select the ‘space’ at the end of the Rich edit control. But we cannot set the
> cursor behind it.(a picture here[3])
> And wine’s riched20 didn’t implement this ‘space’. This 'space' may is the end-
> of-story.
>
> A crash will happen when we copy the ‘space’ from a native Rich edit control to
> a builtin one.(backtrace.txt[4])
>
> BTW, there is a know bug of EM_SETSEL: cannot select the last character of Rich
> edit control.[5]
>
> 3.
> From the last paragraph of this blog: http://blogs.msdn.com/b/murrays/archive/
> 2008/11/22/paragraphs-and-paragraph-formatting.aspx
> It is sure there is a final EOP in a Rich edit control.
>
> There seems to be every indication that we should implement the final EOP of
> Rich edit control rather than just append a ‘\r’ in ITextSelection::GetText.
> So I just let a FIXME comment there. I am not sure if I am right. 
> Do you have any suggestion?

Well first of all, if there are bugs with the underlying richedit,
these need fixing first.  Note, that every richedit consists of at
least one paragraph (and hence one final EOP).

I was suggesting adding to ME_GetTextW the ability to append a '\r' if it
were passed an appropriate flag, of course this wouldn't be the behaviour
used for its current callers.  There's already a diTextEnd item in the
display list to mark the end of the document, so there should be no
need to add a new end-of-story marker.  Most of the iterator functions
stop when this is reached, so you tend not to actually see it, but
that shouldn't be a problem.

Huw.



--
Regards,
Jactry Zeng