Download it now!
Bug 78150 - EDITING: Ctrl+Backspace does not erase first character
Summary: EDITING: Ctrl+Backspace does not erase first character
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
4.3.0.0.alpha1
Hardware: Other Linux (All)
: high critical
Assignee: Julien Nabet
URL:
Whiteboard: target:4.3.0
Keywords: regression
Depends on:
Blocks:
 
Reported: 2014-05-01 11:57 UTC by Cor Nouws
Modified: 2014-05-12 19:56 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Cor Nouws 2014-05-01 11:57:02 UTC
Writer document
Type 'appeltaart' (or something else)
Hit Ctrl+Backspace
 > a remains in the text

(Ctrl+Del to erase the word after the cursor, works fine)
Comment 1 Julien Nabet 2014-05-03 17:44:28 UTC
It seems it was working before thanks to a bug.
Here is why:
- function called by Ctrl backspace is SwWrtShell::DelPrvWord in 
Indeed:sw/source/core/uibase/wrtsh/delete.cxx
(see http://opengrok.libreoffice.org/xref/core/sw/source/core/uibase/wrtsh/delete.cxx#508)
- it calls SwCrsrShell::ExtendSelection from sw/source/core/crsr/crsrsh.cxx
    528                 if( ++n )
    529                     ExtendSelection( false, -n );
Goal and params of this function:
/** extend current SSelection by n characters

    @param bEnd   Start counting from the end? From start otherwise.
    @param nCount Number of characters.
*/
but in 4.2, this function is defined like this:
sal_Bool SwCrsrShell::ExtendSelection( sal_Bool bEnd, xub_StrLen nCount )
whereas in master sources:
2296 bool SwCrsrShell::ExtendSelection( bool bEnd, sal_Int32 nCount )
(see http://opengrok.libreoffice.org/xref/core/sw/source/core/crsr/crsrsh.cxx#2296)

but xub_StrLen was unsigned so -1 for example was converted in 65535

I'm not sure but it seems ExtendSelection expects the second parameter to be not negative since we have this:
   2306     if( bEnd )
   2307     {
   2308         if ((nPos + nCount) <= pTxtNd->GetTxt().getLength())
   2309             nPos = nPos + nCount;
   2310         else
   2311             return false; // not possible
   2312     }
   2313     else if( nPos >= nCount )
   2314         nPos = nPos - nCount;

So it seems DelPrvWord should be changed.

I must keep on investigation cause "// skip over all spaces" means here" is not very clear. Which spaces? Those before or those after the word to delete?
Comment 2 Julien Nabet 2014-05-03 18:35:30 UTC
If we just want to stick to 4.2 behavior, it seems only the spaces at the end of the word must be removed.
eg: if spaces are represented with - and cursor with <>
Here is the behaviour of Ctrl Delete in 4.2 in these different cases:
1) --abcde----fgh--<>
=> --abcde----
2) --abcde----fgh<>--
=> --abcde------

I'll submit for review a patch doing the same thing.
Comment 3 Julien Nabet 2014-05-03 18:40:34 UTC
https://gerrit.libreoffice.org/#/c/9245/
Comment 4 Cor Nouws 2014-05-03 20:41:52 UTC
Hi Julien,

Thanks for looking at this!

(In reply to comment #2)
> If we just want to stick to 4.2 behavior, it seems only the spaces at the
> end of the word must be removed.

Seems that this change was unintended too? If so, something to ask on UX?

Cheers,
Cor
Comment 5 Julien Nabet 2014-05-03 20:47:12 UTC
Indeed! I've just tested with LO 4.1.5.3 Debian package and I've got this:
1) --abcde----fgh--<>
=> --abcde
2) --abcde----fgh<>--
=> --abcde--
Comment 6 Julien Nabet 2014-05-03 21:14:09 UTC
Cor: I found this patch http://cgit.freedesktop.org/libreoffice/core/commit/?id=083114bb132b879cfb899361ece375c8580ae505

Stefan/Michael: what's the expected behavior here?
1) To remove all the spaces before the word just deleted
2) To remove all the spaces but 1 before the word just deleted
3) To remove no spaces before the word just deleted


- https://gerrit.libreoffice.org/#/c/9245/ does 3)
- LO 4.1.5.3 does 1)
- LO 4.2 sources updated some days ago does 3)
(master sources is currently broken since it lets the first character of the delete word)

From https://help.libreoffice.org/Writer/Shortcut_Keys_for_Writer:
"(Ctrl+Backspace)
Delete text to beginning of word
In a list: delete an empty paragraph in front of the current paragraph"

So should be 3)?
Comment 7 Cor Nouws 2014-05-04 12:23:59 UTC
(In reply to comment #6)
> 
> So should be 3)?

Sounds clear and convincing. Thanks.
Comment 8 Commit Notification 2014-05-09 11:53:00 UTC
Julien Nabet committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=6651a2493d72f2bd0613b96ee5276a1270709630

Resolves: fdo#78150 Ctrl+Backspace does not erase first character



The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 9 Julien Nabet 2014-05-12 19:56:51 UTC
Oups, had forgot it. Thank you Michael for having noticed and for your review.