Bug 181563 - DBCS3.3: Hardcoded "Ctrl + Space" for content assist function of remote shell
Summary: DBCS3.3: Hardcoded "Ctrl + Space" for content assist function of remote shell
Status: RESOLVED FIXED
Alias: None
Product: Target Management
Classification: Tools
Component: RSE (show other bugs)
Version: 2.0   Edit
Hardware: PC Linux-GTK
: P3 normal (vote)
Target Milestone: 3.0 M6   Edit
Assignee: Martin Oberhuber CLA
QA Contact: Martin Oberhuber CLA
URL:
Whiteboard:
Keywords: bugday, contributed, greatbug
: 210138 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-04-09 03:29 EDT by Kentaroh Noji CLA
Modified: 2011-05-25 07:19 EDT (History)
6 users (show)

See Also:
mober.at+eclipse: review+


Attachments
Hardcoded content assist key binding (102.29 KB, image/png)
2007-04-09 03:36 EDT, Kentaroh Noji CLA
no flags Details
Screenshot of ContentAssist (124.94 KB, image/png)
2007-04-11 06:28 EDT, Kentaroh Noji CLA
no flags Details
Patch for this bug. (12.19 KB, patch)
2008-02-28 11:20 EST, Radoslav Gerganov CLA
no flags Details | Diff
Patch for this bug (13.62 KB, patch)
2008-02-29 03:16 EST, Radoslav Gerganov CLA
mober.at+eclipse: iplog+
Details | Diff
JVM Backtracke from GTK Crash with the patch (63.39 KB, text/plain)
2008-02-29 13:04 EST, Martin Oberhuber CLA
no flags Details
Another backtrace after changing keyboard shortcuts (48.49 KB, text/plain)
2008-02-29 13:11 EST, Martin Oberhuber CLA
no flags Details
Updated patch from Radoslav against HEAD of 1-Mar-2008 (13.26 KB, patch)
2008-03-03 07:53 EST, Martin Oberhuber CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kentaroh Noji CLA 2007-04-09 03:29:32 EDT
Content assist key binding is hardcoded as "Ctrl + space". "Ctrl + space" is also used for default key binding of activation of Linux Input Method. The content assist key binding must be changed in a preference. 

Build date: 20070405
OS: Redhat Enterprise Linux V5.0       

Steps to recreate problem:
1- Start eclipse in DBCS locale such as ja_JP.UTF-8
2- Open Remote System Explorer perspective
3- Create new connection
4- Launch the remote shell
5- Enter UNIX command such as "ls" in command input field. Then, enter "Ctrl + space".
6- Both IME and content assist are activated. 

Expected output:
Key biding of content assist must not be hardcoded. Key binding must be changed in a preference.
Comment 1 Kentaroh Noji CLA 2007-04-09 03:36:43 EDT
Created attachment 63242 [details]
Hardcoded content assist key binding
Comment 2 Martin Oberhuber CLA 2007-04-10 06:28:13 EDT
What key is used in the Eclipse JDT Editor for content assist in your locale?
Could you attach a screenshot of Preferences > General > Keys showing it?

We should probably just re-use the existing content assist command, by registering a command handler for it. Then it should automatically use the key that's used for content assist in all of Eclipse.
Comment 3 Kentaroh Noji CLA 2007-04-11 06:27:52 EDT
I attached the screenshot of key biding for content assist. Please take a look at  the screenshot.

Comment 4 Kentaroh Noji CLA 2007-04-11 06:28:44 EDT
Created attachment 63483 [details]
Screenshot of ContentAssist
Comment 5 Martin Oberhuber CLA 2007-05-30 08:27:48 EDT
Dave - are you ok if I defer this to the future?
Comment 6 David Dykstal CLA 2007-06-06 10:55:33 EDT
We can fix this either in 2.0.1 or 3.0. I would think it would quite easy to do.
Comment 7 Martin Oberhuber CLA 2007-06-06 11:03:33 EDT
Assigning 2.0.1 if we're confident that there is no API change.
Comment 8 Martin Oberhuber CLA 2007-10-01 07:56:49 EDT
Bulk update target milestone 2.0.1 -> 3.0
Comment 9 Martin Oberhuber CLA 2007-11-16 15:43:40 EST
*** Bug 210138 has been marked as a duplicate of this bug. ***
Comment 10 Radoslav Gerganov CLA 2008-02-25 07:58:11 EST
I will try to prepare a patch for the upcoming BugDay.
Comment 11 Martin Oberhuber CLA 2008-02-25 10:16:00 EST
awsome, thanks ;-)
Comment 12 Radoslav Gerganov CLA 2008-02-28 11:19:33 EST
I have created content assist handler which is binded to the default command for content assistance. This handler is global for all remote shells and when it is activated it provides content assistance for the active shell. The IHandlerService requires org.eclipse.core.expressions so I had added this bundle as a dependency for org.eclipse.rse.shells.ui.

Tomorrow I will be available in #eclipse-bugs and I will be happy to discuss the proposed patch :)
Comment 13 Radoslav Gerganov CLA 2008-02-28 11:20:03 EST
Created attachment 91022 [details]
Patch for this bug.
Comment 14 Martin Oberhuber CLA 2008-02-28 17:25:13 EST
Just reviewing for now, the patch looks great to me. I love patches that actually reduce the amount of code :-) I need to do some testing of it tomorrow.

DaveM can you also review / test the patch please?

Radoslav can you please add your legal message as a bugzilla comment here:
http://www.eclipse.org/dsdp/tm/development/committer_howto.php#external_contrib

Radoslav, on what Platforms have you tested? Windows only or others as well? I'm going to test on ones that you haven't covered yet:-)

I'd also love to see a Unit test but that's supposedly hard with a UI feature like this one.
Comment 15 Martin Oberhuber CLA 2008-02-28 17:26:35 EST
Ah yes, and the copyright dates in the file headers should be increased to read ..., 2008 by IBM and others
Comment 16 Radoslav Gerganov CLA 2008-02-29 03:16:58 EST
Created attachment 91122 [details]
Patch for this bug

Copyright headers updated.

Martin, I have tested only on Windows, feel free to give it a try on other platforms. I agree that making an unit test for this feature will be pretty tough.
Comment 17 Radoslav Gerganov CLA 2008-02-29 03:18:59 EST
I, Radoslav Gerganov, declare that I developed attached code from scratch, without referencing any 3rd party materials except material licensed under the EPL. I am authorized by my employer to make this contribution under the EPL.
Comment 18 Martin Oberhuber CLA 2008-02-29 13:04:38 EST
Created attachment 91216 [details]
JVM Backtracke from GTK Crash with the patch

Hm, patch is perfectly fine on Windows (tested against Eclipse 3.3.2 Target Platform). Tried reassigning content assist to the TAB key and it worked like a charm. Undo (Ctrl+Z) also worked as expected, bringing back the previous entry from the History. I tested on a Windows-Local shell.

On Linux (tested against Ecilpse 3.4M5) there were problems:
* Undo (Ctrl+Z) did not work at all, no action. 
  I tried again on 3.4M5 without the patch, and it worked - so that's clearly
  a regression.
* Reassigning content assist to the Tab key and trying it on a Linux-Local 
  shell made my JVM crash with a SEGV, see below. This was on an RHEL4 box.

Given that the bug was reported against PC-Linux-GTK, I'm reluctant applying the patch into CVS if it can have such negative impact... though that might not be the patch's fault. Anyways, it needs to be investigated. Radoslav, do you have a Linux box available for testing?

My Linux box is RHEL 4 (Nahant Update 3),
Sun Java 1.6.0_01-b03,
gtk2-2.4.13-18,
gtk+-1.2.10-33
/usr/lib/libgtk-x11-2.0.so.0.400.13

#
# An unexpected error has been detected by Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00a58a03, pid=12929, tid=3086875568
#
# Java VM: Java HotSpot(TM) Client VM (1.6.0_01-b06 mixed mode)
# Problematic frame:
# C  [libgtk-x11-2.0.so.0+0x1e0a03]
#
# An error report file with more information is saved as hs_err_pid12929.log
#
# If you would like to submit a bug report, please visit:
#   http://java.sun.com/webapps/bugreport/crash.jsp
#
Comment 19 Martin Oberhuber CLA 2008-02-29 13:11:00 EST
Created attachment 91218 [details]
Another backtrace after changing keyboard shortcuts

Interestingly, the SEGV crash was not reproducable on re-start: Content assist in the RSE Local Shell viat TAB key worked just fine.

Then I wen to Preferences again, and this time I changed Undo from Ctrl+Z to Ctrl+U. Pressed Apply. Back in the Command View, I just typed some characters (did NOT type Ctrl+A)... and ... boom:

#
# An unexpected error has been detected by Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00a58a03, pid=16473, tid=3086875568
#
# Java VM: Java HotSpot(TM) Client VM (1.6.0_01-b06 mixed mode)
# Problematic frame:
# C  [libgtk-x11-2.0.so.0+0x1e0a03]
#
# An error report file with more information is saved as hs_err_pid16473.log
#
# If you would like to submit a bug report, please visit:
#   http://java.sun.com/webapps/bugreport/crash.jsp
#
Comment 20 Martin Oberhuber CLA 2008-02-29 13:15:12 EST
In Eclips eclipse 3.4M5 without the patch, I cannot get the GTK crash to occur - no matter how much I change the keyboard shortcuts, press apply or actually use them in the RSE Command View. It looks like it must have to do something with the patch.

Sorry Radoslav :-(
Comment 21 Martin Oberhuber CLA 2008-03-03 07:53:16 EST
Created attachment 91357 [details]
Updated patch from Radoslav against HEAD of 1-Mar-2008

Patch had to be merged due to moving NLS String CONTENT_ASSIST from rse.ui into rse.shells.ui -- new version is against HEAD as of 1-Mar-2008.
Comment 22 Radoslav Gerganov CLA 2008-03-03 13:32:47 EST
Martin, I have installed Ubuntu 7.10 on my Thinkpad T60 and I can't reproduce these crashes after applying the patch.
First I have tried with Eclipse-SDK-3.3.2-linux-gtk -- clean install, checking out the latest TM sources and applying the patch. Everything was working fine just like on Windows - reassigning keys for both content assist and undo, using the keys and the context menu - no problems at all.
After that I have downloaded Eclipse 3.4M5 and I have found that the Undo command is not working using the key binding and it is disabled in the context menu. However the content assist command was working fine both using the key combination and the context menu. I have restarted Eclipse several times and tried changing keys for content assistance - no problems with it. Next I have reverted the patch and I have found that the Undo command works using Ctrl-Z but it is *always* disabled in the context menu in Eclipse 3.4M5 (both Windows and Linux). Apparently, there are some issues with the Undo command in 3.4M5 which need to be investigated further.
In your stacktraces the crash seems to be caused by g_main_context_iteration and bug 130840 reports the same problem. My guess is that this is GTK bug. Which version of GTK do you use? On my machine "apt-cache show libgtk2.0-0" shows version 2.12.0. I am using JDK 1.6.0_03 from Sun.
Comment 23 Martin Oberhuber CLA 2008-03-04 12:28:09 EST
Thanks Radoslav.

I tried again on the same Linux machine on top of Eclipse-3.3.2 and it worked just fine. Then I tried again on top of Eclipse-3.4M5 and could not reproduce the issue any more. My machine had rebooted since, so perhaps it was related to some odd state of the system.

Anyways, I've committed your patch. Thanks again for the great work. I've commented on bug 130840 regarding the crash.

Are you going to file a bug for the undo issues? It seems you investigated those more than I did. On a quick bugzilla search, I did not find any existing bug describing the issue, so I think we should file one since it appears to be a regression.
Comment 24 Martin Oberhuber CLA 2008-03-04 12:55:59 EST
Verified that the patch is also good on Solaris 10 GTK with Sun 1.5.0 JVM.
Comment 25 Kevin Doyle CLA 2008-07-25 10:09:49 EDT
Martin, Radoslav some questions:

1. With this fix anybody that used the SystemCommandEditor before (User Actions/Compile Commands does) no longer has content assist as adding the handler for content assist proposals to the handler service is done in the SystemCommandsViewPart.  Can we move this back to the SystemCommandEditor or do clients that use SystemCommandEditor now have to add the handler themselves?  This would require clients adding a dependency on org.eclipse.core.expressions.
2. Which bug did the Undo support get fixed with? It is also broken for anyone that use to use SystemCommandEditor.

Thanks.
Comment 26 Martin Oberhuber CLA 2008-07-25 10:34:18 EDT
I don't have the insight to answer these questions (Rado hopefully has), but here's my 2 cents:

  1. I don't see adding a dependency to org.eclipse.core.expressions for 
     clients problematic, that shouldn't be an issue.
  2. I'm against code duplication, so if we can make the Handler such that
     clients don't need to repeat the same stuff I'm in favor of it.

Note, though, that clients who re-use the SystemCommandEditor in a different context might be interested in contributing different content assist strategies anyways, so duplicating the handler might be an advantage rather than a drawback.

As said, though, these are just high-level thoughts since it was Rado who made the fix.
Comment 27 Radoslav Gerganov CLA 2008-07-25 11:08:28 EDT
> 1. With this fix anybody that used the SystemCommandEditor before (User
> Actions/Compile Commands does) no longer has content assist as adding the
> handler for content assist proposals to the handler service is done in the
> SystemCommandsViewPart.  Can we move this back to the SystemCommandEditor or do
> clients that use SystemCommandEditor now have to add the handler themselves? 
> This would require clients adding a dependency on org.eclipse.core.expressions.

The content assist handler is registered in SystemCommandsView because this way it becomes available for all remote shells. I didn't know that SystemCommandEditor could be used outside of the SystemCommandsView.
If we want to move the registration of this handler into the editor, we should investigate how to obtain the IHandlerService in this case and how to define the correct scope of the handler. Currently I am using the part handler service which means that the handler is active when the SystemCommandsViewPart is active.

> 2. Which bug did the Undo support get fixed with? It is also broken for anyone
> that use to use SystemCommandEditor.
> 

It is bug 221392. I believe it is broken because there is no IViewSite in this case and the UndoActionHandler cannot be created (bug 231835). Could you try to set the IViewSite with SystemCommandEditor#setViewSite() to see if it works?
Comment 28 Kevin Doyle CLA 2008-07-28 09:48:56 EDT
> > 2. Which bug did the Undo support get fixed with? It is also broken for anyone
> > that use to use SystemCommandEditor.
> > 
> 
> It is bug 221392. I believe it is broken because there is no IViewSite in this
> case and the UndoActionHandler cannot be created (bug 231835). Could you try to
> set the IViewSite with SystemCommandEditor#setViewSite() to see if it works?
> 

Since the Work With User Actions and Compile Commands are dialogs there is no IViewSite.  It seems we are tied to the view much more closely for undo/content assist now.
Comment 29 Martin Oberhuber CLA 2011-05-25 07:19:38 EDT
Comment on attachment 91122 [details]
Patch for this bug

Patch from Rado was eventually used.