Page 1 of 1

Bug: copy/cut doesn't always work.

Posted: Tue Jul 26, 2011 9:50 am
by johannes
Hi,

I recently found CodeLite. I'm using it for writing some AVR code, and I really like it so far.

I found a little problem. Copy and Cut with the standard key combinations Ctrl+Insert, Shift+Delete doesn't always work. Sometimes, the clipboard is empty after copy or cut. So i copy some text, mark some other text, paste the clipboard with Shift+Insert, and instead of pasting the copied text, an empty string is inserted. This is especially annoying when I used Cut, and then have to Ctrl+Z all the way back to undo the damage.

It only happens every once in a while, I'm guessing every tenth time or so.

Another small thing is that the X clipboard isn't properly utilized (i. e. paste with middle mouse button after marking some text doesn't work). However, that's probably a problem with Scintilla, as Scite and CodeBlocks also had this problem IIRC.

I'm running Ubuntu 11.04, CodeLite version is v2.10.0.4778. If you need any other information please let me know.

edit To clarify, it isn't related to specific key combinations, Ctrl+X or copying/cutting using the context menu works just as unreliable.

Re: Possible bug: copy/cut doesn't always work.

Posted: Tue Jul 26, 2011 2:26 pm
by DavidGH
Hi Johannes,
It only happens every once in a while, I'm guessing every tenth time or so.
That makes it difficult to debug ;) . Testing just now on 11.4 didn't show a problem. If you can find a replicable sequence of actions that makes it happen...

FWIW, I use debian squeeze, and find the same thing happens, very intermittently, with all programs (I blame 'Kipper'). Is it just in CodeLite for you?
Another small thing is that the X clipboard isn't properly utilized
This is cured in wxWidgets svn (2.9). However it'll be a long time before the distros distribute this (they won't think about doing it until it's released as wx3.0). If it's important enough for you, you can build your own CodeLite against wx svn, or the recently released wx2.9.2.

Regards,

David

Re: Possible bug: copy/cut doesn't always work.

Posted: Tue Jul 26, 2011 5:42 pm
by johannes
The X clipboard thing isn't very important for me. It's good to know that it will be fixed in some later release though.

The other problem happens only in CodeLite. Other editors / text entry fields work fine. I'm not using any clipboard utilities like Klipper. I'm running xfce.

I haven't found any replicable sequence of actions to reproduce it. It seems to happen completely at random. I can see that makes it hard to debug. It also makes it very annoying :/

Re: Possible bug: copy/cut doesn't always work.

Posted: Tue Jul 26, 2011 6:46 pm
by DavidGH
I'm running xfce.
Ah, then you're lucky it's working at all ;) : it's an xfce problem. See this CodeLite bug-report.

Re: Possible bug: copy/cut doesn't always work.

Posted: Tue Jul 26, 2011 10:31 pm
by johannes
DavidGH wrote:Ah, then you're lucky it's working at all ;) : it's an xfce problem. See this CodeLite bug-report.
I see. But I don't have the problem in other editors, so it looks to me like some incompatibility between CodeLite and XFCE.

I will try running some clipboard manager plugin, see if I can find a workaround...

Re: Possible bug: copy/cut doesn't always work.

Posted: Wed Jul 27, 2011 2:49 pm
by DavidGH
But I don't have the problem in other editors, so it looks to me like some incompatibility between CodeLite and XFCE.
It's unlikely to be CodeLite itself; more probable is wxScintilla (which CodeLite uses for editor panes) or scintilla itself, on which wxScintilla is based.

If you want to investigate, you could see what happens with the wxWidgets 'stc' sample (which in wx2.8 is inside 'contrib'), and/or with other scintilla-based apps e.g. SciTE.

Re: Possible bug: copy/cut doesn't always work.

Posted: Wed Jul 27, 2011 3:36 pm
by johannes
DavidGH wrote:It's unlikely to be CodeLite itself; more probable is wxScintilla (which CodeLite uses for editor panes) or scintilla itself, on which wxScintilla is based.

If you want to investigate, you could see what happens with the wxWidgets 'stc' sample (which in wx2.8 is inside 'contrib'), and/or with other scintilla-based apps e.g. SciTE.
I regularly use Code::Blocks, which also uses wxScintilla, and haven't had the problem there. I haven't seen the problem in Scite, either.

Re: Possible bug: copy/cut doesn't always work.

Posted: Sun Aug 28, 2011 4:35 pm
by johannes
[bump]
Is anyone looking into this? Copy&Paste is one of the fundamental basics of a text editor, so it should be kind of important? CodeLite redistributes the WXScintilla component in source form, so even if the bug is located there, I guess it's kind of the responsibility of CodeLite to at least look into the problem. No?

For a start, I found this in ScintillaWX.cpp:

Code: Select all

void ScintillaWX::Copy() {
	if ( !sel.Empty() ) {
		SelectionText st;
		CopySelectionRange(&st);
#ifdef __WXGTK__
		for(int i=0; i<5; i++) {
			//wxPrintf(wxT("Copying to clipboard %ld\n"), i);
			CopyToClipboard(st);
		}
#else
		CopyToClipboard(st);
#endif
	}
}
This looks suspicious to me. Why would you need to copy it 5 times?

Re: Bug: copy/cut doesn't always work.

Posted: Sun Aug 28, 2011 8:37 pm
by eranif
johannes wrote:This looks suspicious to me. Why would you need to copy it 5 times?
Because couple of years ago I found the same bug under KDE, however, what seems to fix the problem was copying the same text again.
So I added a loop for copying the same text 5 times - this seems to fix the problem and it was never reported again - until now.
johannes wrote:Is anyone looking into this? Copy&Paste is one of the fundamental basics of a text editor, so it should be kind of important?
It is, however, I can't reproduce it here (Ubuntu 11.4 64 and 32 bit), David was unable to get this problem as well - so its kinda hard to fix a problem that you can't reproduce ...

I will look into it again and see if there anything that I can workaround
Eran

Re: Bug: copy/cut doesn't always work.

Posted: Sun Aug 28, 2011 10:34 pm
by johannes
eranif wrote:It is, however, I can't reproduce it here (Ubuntu 11.4 64 and 32 bit), David was unable to get this problem as well - so its kinda hard to fix a problem that you can't reproduce ...

I will look into it again and see if there anything that I can workaround
Thanks! If I get around to it, I will also look into the code some more. Other things maybe worth mentioning:
- I can reproduce it on two machines, my desktop machine and the netbook. Both run Ubuntu 10.04 32 bit, both run XFCE. So XFCE might be a factor. Although all other editors (also those using (wx)scintilla) don't have the problem.
- CodeBlocks seems to bundle their own customized version of wxScintilla (reported as a "bug" here). The CodeBlocks editor component works for me. Maybe checking what they do differently might give some insight?