Bug 248558 - Marked text is cut out when switching between documents (ibus input method)
Summary: Marked text is cut out when switching between documents (ibus input method)
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: part (show other bugs)
Version: unspecified
Platform: Gentoo Packages Linux
: HI major
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
: 220308 249772 252215 257225 257467 266394 284558 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-08-20 23:11 UTC by J.O. Aho
Modified: 2011-12-01 08:01 UTC (History)
13 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Bt at 'KateView::removeSelectedText()' (7.56 KB, text/plain)
2010-08-23 13:25 UTC, Niklas Laxström
Details

Note You need to log in before you can comment on or make changes to this bug.
Description J.O. Aho 2010-08-20 23:11:03 UTC
Version:           unspecified (using KDE 4.4.5) 
OS:                Linux

If you mark a text in document A and switch to document B and then back to document A, the marked text is cut out.

Reproducible: Always

Steps to Reproduce:
1. Open 2 documents
2. Mark a part of the text in first document
3. Switch to second document
4. Switch back to first document

Actual Results:  
The marked text has disappeared.

Expected Results:  
You would see the marked text.

There seems to be a number of people who has had this problem (most of those have thought the bug is in Kdevelop, but it's in Kate), with different distributions.

The option "Editing / General / Copy/Cut the current line if no selection" is disabled.

I have tried to delete all Kate configurations, but the problem is still there (enable and then disable the Copy/Cut feature don't make any change, it seems to make things slightly worse).

This is extremely bad when you code and do some copy between your source and header files, suddenly you are missing code.
Comment 1 Dominik Haumann 2010-08-20 23:22:37 UTC
*** Bug 220308 has been marked as a duplicate of this bug. ***
Comment 2 Dominik Haumann 2010-08-20 23:25:01 UTC
This is probably a input mode issue. What input mode do you use? In bug #248558 the bug seems to reproducible with IBus.
Comment 3 J.O. Aho 2010-08-21 13:13:18 UTC
Yes, I do have IBus installed, not personally using it, but I have someone else who does use it to write traditional Chinese.
Comment 4 Niklas Laxström 2010-08-22 17:55:15 UTC
I'm having this too, and yes I have iBus enabled (and have had a lots of problems due to it).
Comment 5 Pascal Létourneau 2010-08-22 22:46:35 UTC
Can somebody start kate in a debugger

$ gdb kate
(gdb) b 'KateView::removeSelectedText()'   

Do whatever you need to reproduce the bug

(gdb) bt

and paste the backtrace here
Comment 6 Niklas Laxström 2010-08-23 13:25:24 UTC
Created attachment 50862 [details]
Bt at 'KateView::removeSelectedText()'

Here's a such backtrace.
Comment 7 Pascal Létourneau 2010-08-23 21:00:54 UTC
Thanks

Does this patch fix it for you

Index: kate/view/kateviewinternal.cpp
===================================================================
--- kate/view/kateviewinternal.cpp      (revision 1144411)
+++ kate/view/kateviewinternal.cpp      (revision 1144412)
@@ -3574,9 +3574,6 @@ void KateViewInternal::inputMethodEvent(

   //kDebug( 13030 ) << "Event: cursor" << m_cursor << "commit" << e->commitString() << "preedit" << e->preeditString() << "replacement start" << e->replacementStart() << "length" << e->replacementLength();

-  if ( m_view->selection() )
-    m_view->removeSelectedText();
-
   bool createdPreedit = false;
   if (!m_imPreeditRange) {
     createdPreedit = true;
@@ -3590,6 +3587,8 @@ void KateViewInternal::inputMethodEvent(
   }

   if (!e->commitString().isEmpty() || e->replacementLength()) {
+    m_view->removeSelectedText();
+
     KTextEditor::Range preeditRange = *m_imPreeditRange;

     KTextEditor::Cursor start(m_imPreeditRange->start().line(), m_imPreeditRange->start().column() + e->replacementStart());
Comment 8 Niklas Laxström 2010-08-23 21:35:30 UTC
(In reply to comment #7)
> Thanks
> 
> Does this patch fix it for you

I don't have environment set up to compile kate myself, so it's not easy for me to test this patch.
Comment 9 J.O. Aho 2010-08-23 22:59:02 UTC
Do you have a similar patch for Kate version 3.4.5 (this is the one which comes with KDE 4.4.5 in Gentoo)? If so, then I can try out the patch as that version don't have the kateviewinternal.cpp, so can't use your current patch.
Comment 10 Pascal Létourneau 2010-08-23 23:06:11 UTC
You need to apply the patch in kdelibs
Comment 11 J.O. Aho 2010-08-23 23:42:37 UTC
The patch seems to fix my problem.
Comment 12 Zane Tu 2010-10-17 20:25:43 UTC
Same problem. The bug occurs only when using ibus. I'm using Kate v3.5.1 with KDE 4.5.1 (Kubuntu 10.10 amd64).
Comment 13 Zane Tu 2010-10-21 08:38:57 UTC
This bug occurs in chromium v8.0.558.0 as well. But it doesn't occur in Firefox v3.6.10. Just FYI.
Comment 14 Dominik Haumann 2010-10-26 15:39:07 UTC
*** Bug 252215 has been marked as a duplicate of this bug. ***
Comment 15 Zane Tu 2010-10-30 11:28:49 UTC
This bug occurs in Firefox v3.6.12 when editing Google Docs. Just FYI.
Comment 16 Dominik Haumann 2010-11-21 10:57:50 UTC
*** Bug 257225 has been marked as a duplicate of this bug. ***
Comment 17 Dominik Haumann 2010-11-21 23:03:57 UTC
Hi everyone. Someone with this problem now has to compile Kate according to http://kate-editor.org/get-it/
Then, change the lines in kateviewinternal.cpp according to comment #7 and report here whether this problem is then fixed.

If you do not test it, this will not get resolved. So we really rely on your cooperation here! Thanks a lot :)
Comment 18 Dominik Haumann 2010-11-21 23:05:10 UTC
Pascal, in comment #11 we even have already someone who says your patch fixes the issue. What about committing for 4.6? It should have gone into beta1, a pity.
Comment 19 Madison Kelly 2010-11-21 23:20:15 UTC
*** Bug 257467 has been marked as a duplicate of this bug. ***
Comment 20 Madison Kelly 2010-11-21 23:21:28 UTC
Closed #257467 as a duplicate of this bug. Note that the same "delete highlighted" happens when closing the search bar with text highlighted.
Comment 21 Pascal Létourneau 2010-11-21 23:49:19 UTC
It's in trunk since June
According to comment #43 of bug 220308 it was not working
That's why I didn't backport at that time
I will backport
Comment 22 Pascal Létourneau 2010-11-21 23:54:15 UTC
SVN commit 1199457 by pletourn:

Remove selection only when receiving input

CCBUG:248558


 M  +2 -3      kateviewinternal.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1199457
Comment 23 Dominik Haumann 2010-11-22 09:36:45 UTC
Ah ok, wasn't aware that it's in trunk!

> According to comment #43 of bug 220308 it was not working

In other words, we still need more people compiling Kate http://kate-editor.org/get-it/ and report back what happens (no need to apply the patch, it's already applied).
Comment 24 dector 2010-12-13 10:28:04 UTC
(In reply to comment #23)
> Ah ok, wasn't aware that it's in trunk!
> 
> > According to comment #43 of bug 220308 it was not working
> 
> In other words, we still need more people compiling Kate
> http://kate-editor.org/get-it/ and report back what happens (no need to apply
> the patch, it's already applied).

I have this bug and I confirm that compiling Kate solves it.

FYI, this bug only appears if ibus sends editable text to the editor. It can be disabled by unselecting "Embed preedit text in application window" option in ibus-setup. Thus, it provides a work-around when ibus input is not needed.
Comment 25 Madison Kelly 2010-12-13 17:02:07 UTC
I recompiled with the edit mentioned and this solved the problem for me as well.
Comment 26 Dominik Haumann 2011-02-15 23:07:54 UTC
*** Bug 266394 has been marked as a duplicate of this bug. ***
Comment 27 Dominik Haumann 2011-03-06 10:02:07 UTC
*** Bug 249772 has been marked as a duplicate of this bug. ***
Comment 28 Dominik Haumann 2011-10-21 21:05:08 UTC
So if I understand correctly, this report can be closed as fixed? Please confirm.
Comment 29 Jekyll Wu 2011-11-22 11:16:16 UTC
I do not have this problem when using ibus-1.4.0 and kate-3.7.3.
Comment 30 Jekyll Wu 2011-12-01 08:01:42 UTC
*** Bug 284558 has been marked as a duplicate of this bug. ***