Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PyDev: Autocomplete opens outside insert mode by moving cursor, even when disabled #785

Open
timdiels opened this issue Jun 16, 2017 · 9 comments

Comments

@timdiels
Copy link

To reproduce, make a file test.py containing this line 'abcde'. Place cursor at the start of the line, enter insert mode and type a single letter (e.g. ia), exit insert mode and now ll or fa to move the cursor to a, when moving from ' to a, autocomplete will pop up. I expect autocomplete never to pop up while not in edit mode, or at least in this case I wouldn't expect it to pop up.

I tested with stable Vrapper (0.72.0).

Eclipse version:

Eclipse IDE for C/C++ Developers

Version: Neon.1a Release (4.6.1)
Build id: 20161007-1200

Installed software (eclipse):

  C/C++ Autotools support	9.1.0.201609121658	org.eclipse.cdt.autotools.feature.group	Eclipse CDT
  C/C++ Development Tools	9.1.0.201609121658	org.eclipse.cdt.feature.group	Eclipse CDT
  C/C++ GCC Cross Compiler Support	9.1.0.201609121658	org.eclipse.cdt.build.crossgcc.feature.group	Eclipse CDT
  C/C++ Library API Documentation Hover Help	5.1.0.201609141916	org.eclipse.linuxtools.cdt.libhover.feature.feature.group	Eclipse Linux Tools
  C/C++ Memory View Enhancements	9.1.0.201609121658	org.eclipse.cdt.debug.ui.memory.feature.group	Eclipse CDT
  C/C++ Remote Launch	9.1.0.201609121658	org.eclipse.cdt.launch.remote.feature.group	Eclipse CDT
  CDT Standalone Debugger Support	9.1.0.201609121658	org.eclipse.cdt.debug.standalone.feature.group	Eclipse CDT
  ChangeLog Management Tools for C/C++	5.1.0.201609141916	org.eclipse.linuxtools.changelog.c.feature.group	Eclipse Linux Tools
  e(fx)clipse - IDE	2.1.0.201508240705	org.eclipse.fx.ide.feature.feature.group	Eclipse.org
  Eclipse Git Team Provider	4.4.1.201607150455-r	org.eclipse.egit.feature.group	Eclipse EGit
  Eclipse IDE for C/C++ Developers	4.6.1.20161007-1200	epp.package.cpp	Eclipse Packaging Project
  Eclipse Java Development Tools	3.11.1.v20150904-0015	org.eclipse.jdt.feature.group	Eclipse.org
  GCov Integration	5.1.0.201609141916	org.eclipse.linuxtools.gcov.feature.group	Eclipse Linux Tools
  GDB Tracepoint Analysis	2.1.0.201609141510	org.eclipse.tracecompass.gdbtrace.feature.group	Eclipse Trace Compass
  GProf Integration	5.1.0.201609141916	org.eclipse.linuxtools.gprof.feature.feature.group	Eclipse Linux Tools
  Groovy-Eclipse Feature	2.9.2.xx-201703131833-e46	org.codehaus.groovy.eclipse.feature.feature.group	Codehaus.org
  Library Hover help for devhelp documentation	5.1.0.201609141916	org.eclipse.linuxtools.cdt.libhover.devhelp.feature.feature.group	Eclipse Linux Tools
  LTTng Kernel Analysis	2.1.0.201609141510	org.eclipse.tracecompass.lttng2.kernel.feature.group	Eclipse Trace Compass
  LTTng Tracer Control	2.1.0.201609141510	org.eclipse.tracecompass.lttng2.control.feature.group	Eclipse Trace Compass
  LTTng Userspace Analysis	2.1.0.201609141510	org.eclipse.tracecompass.lttng2.ust.feature.group	Eclipse Trace Compass
  m2e - Maven Integration for Eclipse (includes Incubating components)	1.6.2.20150902-0002	org.eclipse.m2e.feature.feature.group	Eclipse.org - m2e
  Mylyn Context Connector: C/C++ Development	5.16.0.v20160421-1902	org.eclipse.cdt.mylyn.feature.group	Eclipse Mylyn
  Mylyn Context Connector: Eclipse IDE	3.20.0.v20160421-1902	org.eclipse.mylyn.ide_feature.feature.group	Eclipse Mylyn
  Mylyn Context Connector: Team Support	3.20.0.v20160421-1902	org.eclipse.mylyn.team_feature.feature.group	Eclipse Mylyn
  Mylyn Task List	3.20.0.v20160608-1838	org.eclipse.mylyn_feature.feature.group	Eclipse Mylyn
  Mylyn Task-Focused Interface	3.20.0.v20160608-1905	org.eclipse.mylyn.context_feature.feature.group	Eclipse Mylyn
  Mylyn Tasks Connector: Bugzilla	3.20.0.v20160425-1835	org.eclipse.mylyn.bugzilla_feature.feature.group	Eclipse Mylyn
  Mylyn WikiText	2.9.0.v20160601-1831	org.eclipse.mylyn.wikitext_feature.feature.group	Eclipse Mylyn
  PyDev for Eclipse	4.4.0.201510052309	org.python.pydev.feature.feature.group	Fabio Zadrozny
  Remote System Explorer End-User Runtime	3.7.1.201603211627	org.eclipse.rse.feature.group	Eclipse TM Project
  RPM Tools	5.1.0.201609141916	org.eclipse.linuxtools.rpm.feature.group	Eclipse Linux Tools
  Valgrind Tools Integration	5.1.0.201609141916	org.eclipse.linuxtools.valgrind.feature.group	Eclipse Linux Tools
  Vrapper	0.72.0	net.sourceforge.vrapper.feature.group	Vrapper Team
  Vrapper - Python Extensions (Optional, requires PyDev)	0.72.0	net.sourceforge.vrapper.eclipse.pydev.feature.feature.group	Vrapper Team
  Vrapper - vim-indent-object.vim Plugin (Optional)	0.72.0	net.sourceforge.vrapper.plugin.indenttextobj.feature.group	Vrapper Team
@timdiels
Copy link
Author

timdiels commented Jun 16, 2017

Also happens in unstable (0.73.20170320), even after uninstalling these:

  Vrapper - Python Extensions (Optional, requires PyDev)	0.72.0	net.sourceforge.vrapper.eclipse.pydev.feature.feature.group	Vrapper Team
  Vrapper - vim-indent-object.vim Plugin (Optional)	0.72.0	net.sourceforge.vrapper.plugin.indenttextobj.feature.group	Vrapper Team

@albertdev
Copy link
Member

albertdev commented Jun 16, 2017

In the title you're saying "even when disabled". Does this mean you get the popup even if Vrapper is toggled so that it reads "vrapper disabled" in the Eclipse status line?

If so, it is unlikely we're going to be able to do anything about this as it is PyDev which chooses to open an autocomplete window.

@timdiels
Copy link
Author

I was referring to unchecking all the options on both Code Completion tabs in PyDev's configuration, not disabling vrapper (I haven't tried that, not sure how to do that).

@albertdev
Copy link
Member

albertdev commented Jun 19, 2017

With disabling Vrapper I mean clicking the Vim icon in the toolbar:

Vrapper toggle icon

It doesn't really matter though: I've setup a local install of PyDev and was able to reproduce your scenario, with Vrapper disabled there is no popup if I just use the arrow keys to move right after inserting an a and moving right.

I have no idea why PyDev would react this way to Vrapper's actions. I might try to toy with it for a bit but no promises...

EDIT: More remarks:

  • The popup never seems to happen using the arrow keys, it's only using h or l.
  • Closing it will not make it appear again until something is changed in the file. Maybe this is something we can use to our advantage.

EDIT 2:

  • Something else I noticed is that it only triggers when moving right. Jumping to the end doesn't seem to be a problem. but then moving to the right with l will still trigger the popup.
  • Even weirder: moving right using <space> doesn't seem to trigger anything, even though Vrapper should in theory be using the same APIs.

@timdiels
Copy link
Author

timdiels commented Sep 4, 2017

It's not specific to PyDev, it also happens with PDT (PHP development tools)

@albertdev
Copy link
Member

@timdiels I haven't really debugged the PDT code but a quick grep in their sources shows the same problem: their code is not compatible with Vrapper because they bypass Eclipse JFace and register listeners on SWT widgets directly.

Vrapper works with JFace because JFace editors have a method "prependVerifyKeyListener" which will make sure that Vrapper comes first to suppress certain keys. When PDT registers SWT KeyListeners, those keys are always handled by PDT before Vrapper sees them so Vrapper can do nothing about them.

@tdfesuom
Copy link

tdfesuom commented Jan 2, 2021

I have same problem in a Eclipse EDA editor. Steps like this:

  1. First , insert mode, input some character.
  2. Then ESCape to Normal mode
  3. Press j or k to another line, this will trigger content assistant proposal popup.

But press Arrow up/down not j/k will not trigger proposal popup.

In My EDA editor based on AbstractTextEditor , is there some method to get Vrapper mode, so I can prohibit the proposal popup when in normal mode.

@tdfesuom
Copy link

tdfesuom commented Jan 2, 2021

I add the following code in my ContentAssistProcessor, the problem solved.

Class HdlCompletionProcessor implements IContentAssistProcessor {
....
private String getMode() {
final String name = "VimInputMode" + super.fEditor.getEditorSite().getId();
final IStatusLineManager manager = super.fEditor.getEditorSite().getActionBars().getStatusLineManager();
IContributionItem item = manager.find(name);

    if (item != null) {;
        try {
			Class itemClass = item.getClass();
			Field modeField = itemClass.getDeclaredField("mode");
			
			if (modeField != null) {
				modeField.setAccessible(true);
				return (String)modeField.get(item);
			}
		} catch (Exception e) {
		}
    }
    
    return "";
}

public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer,int documentOffset) {
String mode = getMode();

	if(mode.toLowerCase().contains("normal")) return null;
	if(mode.toLowerCase().contains("visual")) return null;
            ....

}

.....
}

@tdfesuom
Copy link

tdfesuom commented Jan 2, 2021

By the way, my contentassistant processor use the following auto-trigger characters

public char[] getCompletionProposalAutoActivationCharacters()
{
	String strChs = ".abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
	return strChs.toCharArray();
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants