Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 363501

Summary: Wrong word selection on double click
Product: [Tools] LDT Reporter: Julien Desgats <jdesgats>
Component: LuaDevelopmentToolsAssignee: Benjamin Cabé <contact>
Status: RESOLVED FIXED QA Contact:
Severity: minor    
Priority: P3 CC: contact, malaperle
Version: unspecified   
Target Milestone: 0.8 RC1   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
mylyn/context/zip
none
Double click detector patch
none
Editor test plugin
none
Double click detector including tests none

Description Julien Desgats CLA 2011-11-10 11:37:50 EST
When a word is double-clicked, the word selection selects tokens over the word under the cursor. 

For instance with "local var = foo.ba[]r.baz(1,2,3)" ([] is the caret), a double click would select "foo.bar.baz" but it shold select only "bar".
Comment 1 Julien Desgats CLA 2011-11-23 14:22:56 EST
A little precision: my first example is wrong, the tokens separated by dots are correctly selected. 

This is actually the colon which makes wrong selection, so the wrong example is "local var = foo.ba[]r:baz(1,2,3)" ([] is the caret) will select the whole "foo.bar:baz".
Comment 2 Marc-André Laperle CLA 2012-01-17 17:35:41 EST
I have a simple example:

foo:bar()

I double-click on foo, foo:bar is selected.
Comment 3 Benjamin Cabé CLA 2012-01-18 16:22:07 EST
Attaching a Mylyn context.
Behavior on double-click happens in LuaSourceViewerConfiguration (need to override SourceViewerConfiguration#getDoubleClickStrategy(ISourceViewer, String))
Comment 4 Benjamin Cabé CLA 2012-01-18 16:22:09 EST
Created attachment 209704 [details]
mylyn/context/zip
Comment 5 Marc-André Laperle CLA 2012-01-24 11:49:38 EST
(In reply to comment #3)
> Attaching a Mylyn context.
> Behavior on double-click happens in LuaSourceViewerConfiguration (need to
> override SourceViewerConfiguration#getDoubleClickStrategy(ISourceViewer,
> String))

Thanks for the info, I will work on this.
Comment 6 Marc-André Laperle CLA 2012-02-05 01:25:18 EST
Created attachment 210544 [details]
Double click detector patch

This patch adds a double click detector. It is inspired by DLTK and CDT but has a slight modification that makes it behave closer to JDT. If double click is done on the right of the word, the word is not selected. I split the test plugin in a separate zip because I had troubles making a patch that would apply with all the changes.
Comment 7 Marc-André Laperle CLA 2012-02-05 01:26:49 EST
Created attachment 210545 [details]
Editor test plugin
Comment 8 Benjamin Cabé CLA 2012-02-07 15:45:28 EST
Thanks a lot Marc-André! I'll try to review the patch this week, but it looks great (and from the few smoke tests I performed, it works great too :-)).

FWIW, this contribution will need a CQ since it is slightly bigger than 250 lines, but I think this won't take too long...
Comment 9 Benjamin Cabé CLA 2012-02-15 17:21:23 EST
Marc-André, the patch looks great!

Could you please try to provide a patch which contains both the fix and the tests? I have had no peculiar issues squashing the two patches into one single commit ; let me know if I can help.
Also, can you please double-check the license headers in the files you either modified or created?
- LuaWordFinder: the first line should be "Copyright (c) 2012 Marc-Andre Laperle and others."
- org.eclipse.koneki.ldt.editor.tests#Activator should also have a copyright header similar to LuaWordFinderTest (even though that's probably arguable), and you may want to remove the "@author     Kevin KIN-FOO <kkinfoo@anyware-tech.com>" mention too (as well as the "// TODO: Auto-generated Javadoc" by the way!)
- same remarks for org.eclipse.koneki.ldt.editor.tests#Suite

Alsom can you then please confirm in a comment that:
(a) you wrote 100% of the code or reused EPL code from ecipse.org
(b) you have the right to contribute the code to Eclipse


Thanks so much!
Comment 10 Marc-André Laperle CLA 2012-02-16 19:44:40 EST
(In reply to comment #9)
> Also, can you please double-check the license headers in the files you either
> modified or created?
> - LuaWordFinder: the first line should be "Copyright (c) 2012 Marc-Andre
> Laperle and others."

Even though IBM wrote the initial implementation? I really just copied the file and Refactored/Extracted a couple of methods. I thought when copying a file like that, the initial copyright owner should be kept (at least that's what I've seen when working on CDT) but the text is not very clear on that IMO:

"{INITIAL COPYRIGHT OWNER} is the copyright owner that created the initial content. If the content is subsequently modified and appended to by other copyright owners, the words "and others" are typically appended."
http://www.eclipse.org/legal/copyrightandlicensenotice.php

> - org.eclipse.koneki.ldt.editor.tests#Activator should also have a copyright
> header similar to LuaWordFinderTest (even though that's probably arguable),

I left the copyrights since those files are basically just renamed versions of other ldt tests files but I can change them.

> you may want to remove the "@author     Kevin KIN-FOO
> <kkinfoo@anyware-tech.com>" mention too (as well as the "// TODO:
> Auto-generated Javadoc" by the way!)

Will do!

> Also can you then please confirm in a comment that:
> (a) you wrote 100% of the code or reused EPL code from ecipse.org
> (b) you have the right to contribute the code to Eclipse

a) I wrote 100% of the code and reused EPL code from eclipse.org
b) I have the right to contribute code to Eclipse. (I'm a committer on CDT BTW)
Comment 11 Benjamin Cabé CLA 2012-02-22 18:07:29 EST
I tend to agreed with your remarks Marc-André, and I think that will do!
If you can provide an updated single patch, with the few TODOs removed, I'll open the CQ. I am not sure it can make it for Juno, but I really do hope so though... (you may not have seen that, but we are trying to join the Juno train).
Comment 12 Marc-André Laperle CLA 2012-02-22 20:04:05 EST
Created attachment 211465 [details]
Double click detector including tests

Generated with git format-patch.
Comment 13 Benjamin Cabé CLA 2012-02-23 03:50:49 EST
Thanks! I opened https://dev.eclipse.org/ipzilla/show_bug.cgi?id=6280
Comment 14 Benjamin Cabé CLA 2012-04-01 11:56:47 EDT
Thank you again Marc-André, your patch made it to master... at last! (commit aee5d8b).

Marking as FIXED.