Bug 34786 - [EasyHack]Editing: Sentence movement function broken
Summary: [EasyHack]Editing: Sentence movement function broken
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: x86 (IA32) All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: easyHack
Depends on:
Blocks:
 
Reported: 2011-02-26 19:35 UTC by seatrout
Modified: 2015-12-18 09:58 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
basic macros illustrating and fixing problem (3.09 KB, text/plain)
2011-02-26 19:35 UTC, seatrout
Details
improved, now comprehensible macro workaround (2.76 KB, text/plain)
2011-02-27 04:21 UTC, seatrout
Details

Note You need to log in before you can comment on or make changes to this bug.
Description seatrout 2011-02-26 19:35:59 UTC
Created attachment 43865 [details]
basic macros illustrating and fixing problem

The navigation commands to move (and delete) to the previous sentence are broken and will frequently move two sentences back instead of one. If the sentence is the first in a paragraph, they will not move beyond it; if it is the last in a paragraph, they move two sentences. 

This behaviour has been broken in OOo for years, since version 2.0. I wrote a macro which gets round it in about 2004. It is rather disappointing to find it's still broken.
Comment 1 Rainer Bielefeld Retired 2011-02-27 00:19:22 UTC
@seatrout
Please explain 
- what "the" problem is you are talking about; 
  <Ctrl+Shift+Backspace> to delete text to beginning of sentence? 
  I know the "deletes e2 sentences at end of paragraph" problem.
- how to use your macro to illustrate and fix the problem.

Please contribute information concerning your OS and with what LibO version you saw the problem the first time.
Comment 2 seatrout 2011-02-27 04:10:53 UTC
(In reply to comment #1)
> @seatrout
> Please explain 
> - what "the" problem is you are talking about; 
>   <Ctrl+Shift+Backspace> to delete text to beginning of sentence? 
>   I know the "deletes e2 sentences at end of paragraph" problem.
> - how to use your macro to illustrate and fix the problem.
> 
> Please contribute information concerning your OS and with what LibO version you
> saw the problem the first time.

Reiner, thank you for responding so quickly. I will try to answer as clearly as possible.

There are two cases in which move-backwards-by-sentence is broken. They may be two different bugs. I noticed them at the same time, and assumed they were the same one. 

The first problem is that the command listed under customisation as "to previous sentence" seems always to move two sentences backwards when invoked at the end or in the middle of a paragraph. Try inserting a paragraph of dummy text and invoking this. 

My macro gets round this by using the command to go to the *start* of the present sentence, rather than the *previous* sentence. But the start of a sentence is not the position after the full stop at the end of the sentence, but the position after the space that follows a full stop. I am not sure if this is a bug, but I think it is. So if I am at the start of a sentence, I move one char left, and then to the beginning of the previous sentence. That way, pressing the macro repeatedly moves me through the document, as I want. 

The trouble is that the macro has been through so many iterations to deal with the ways in which this has broken since 2004 that I realised when I sat down to look at it that I no longer understood how or why it worked. Except it does. Here is a simplified version simply showing how to move backwards through a document one sentence at a time on successive keypresses, while avoiding the two-sentence jump.
Comment 3 seatrout 2011-02-27 04:21:02 UTC
Created attachment 43870 [details]
improved, now comprehensible macro workaround

This is a pair of simple macros showing a workaround to the bug using start of sentence, rather than "previous sentence"
Comment 4 Rainer Bielefeld Retired 2011-02-27 08:21:12 UTC
@seatrout:
I did some quick tests and both macros seem to work.

To make them really valuable they should be listed with a short description on a (currently not existing) WIKI page like
<http://www.ooowiki.de/ÜbersichtMakros>
I believe such a selection of macro snippets would be rather useful for experienced users with few time to create such tools themselves.

A second step would be an extension, may be with integrated creation of a little toolbar that makes the macros clickable? I know that from Extension "Multipages", but I do not know how to add such a function.

I started a discussion with subject "Basic Macro Snippets collection" on <discuss@documentfoundation.org>
Comment 5 Rainer Bielefeld Retired 2011-02-27 08:25:42 UTC
@seatrout:
Do you know the OOo issue number? It seems we do not have the bug already reported here, may be you can file a report concerning the bug?
Comment 6 Cédric Bosdonnat 2011-02-28 02:15:55 UTC
This is an easy hack. The code for these moves is located here:
http://opengrok.libreoffice.org/xref/writer/sw/source/ui/inc/wrtsh.hxx#FwdSentence

I would much prefer having the core code fixed rather than integrating some macro to workaround it.
Comment 7 Jeffrey 2011-05-29 22:55:43 UTC
Hi,

I am new to the LibreOffice community and I would like to contribute in any way possible. Since I have had only two years of experiences with C++ code, I was thinking of looking at some simpler Easy Hacks to start with and I took a look at this one.

I traced the error to which I think is the _BwdSentence() function in wrtsh4.cxx here:
http://opengrok.libreoffice.org/xref/writer/sw/source/ui/wrtsh/wrtsh4.cxx#_BwdSentence
Instead of !GoPrevSentence() in line 237, I think that it should be !GoStartSentence() because the former will take the pointer to the beginning of the previous sentence, and hence when the user calls CTRL+SHIFT+DEL, it will delete not only to the beginning of the sentence, but the entire previous sentence as well. By making this simple fix, I have tested Writer and it seems to resolve this issue at this point.

I am not sure if I am entirely interpreting this EasyHack problem correctly or if my change will affect other areas of the program, so if any one else has advice on what else to try, please tell me. Also, if anyone would be willing to indicate that this is a suitable core code fix, that would be great as well. Thanks.
Comment 8 Cédric Bosdonnat 2011-05-30 01:25:21 UTC
(In reply to comment #7)
> I traced the error to which I think is the _BwdSentence() function in
> wrtsh4.cxx here:
> http://opengrok.libreoffice.org/xref/writer/sw/source/ui/wrtsh/wrtsh4.cxx#_BwdSentence
> Instead of !GoPrevSentence() in line 237, I think that it should be
> !GoStartSentence() because the former will take the pointer to the beginning of
> the previous sentence, and hence when the user calls CTRL+SHIFT+DEL, it will
> delete not only to the beginning of the sentence, but the entire previous
> sentence as well. By making this simple fix, I have tested Writer and it seems
> to resolve this issue at this point.

Your change looks reasonable to me. Could you please attach the result of git format-patch to the mailing list to help us integrate your patch and start to get in touch with the other developers?
Comment 9 LeMoyne Castle 2011-05-31 01:41:04 UTC
(In reply to comment #7)
> Hi,
> 
> I am new to the LibreOffice community and I would like to contribute in any way
> possible. Since I have had only two years of experiences with C++ code, I was
> thinking of looking at some simpler Easy Hacks to start with and I took a look
> at this one.
> 
> I traced the error to which I think is the _BwdSentence() function in
> wrtsh4.cxx here:
> http://opengrok.libreoffice.org/xref/writer/sw/source/ui/wrtsh/wrtsh4.cxx#_BwdSentence
> Instead of !GoPrevSentence() in line 237, I think that it should be
> !GoStartSentence() because the former will take the pointer to the beginning of
> the previous sentence, and hence when the user calls CTRL+SHIFT+DEL, it will
> delete not only to the beginning of the sentence, but the entire previous
> sentence as well. By making this simple fix, I have tested Writer and it seems
> to resolve this issue at this point.
> 
> I am not sure if I am entirely interpreting this EasyHack problem correctly or
> if my change will affect other areas of the program, so if any one else has
> advice on what else to try, please tell me. Also, if anyone would be willing to
> indicate that this is a suitable core code fix, that would be great as well.
> Thanks.
Comment 11 Robinson Tryon (qubit) 2015-12-18 09:58:35 UTC
Migrating Whiteboard tags to Keywords: (EasyHack)
[NinjaEdit]