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

Could autocompletion for naming things be made less aggressive? Or have a setting to disable it? #511

Closed
rlundy opened this issue Apr 18, 2018 · 3 comments

Comments

@rlundy
Copy link

rlundy commented Apr 18, 2018

In VS Code, in a Java project, I've found that name suggestions are replacing my actual typed text. For example, in this custom code snippet...

public WebElement ELEMENTNAME() {
    return driver.findElementByCssSelector("CSSSELECTOR");
}

...the two all-caps items are tab stops. I type, say, cancelButton in the first field, tab to the second, and find that ELEMENTNAME has instead been replaced with cancelButtonElement, because for some reason that was a naming suggestion.

This seems problematic because (a) the name I typed is being overridden with no notice, and (b) it's not even a better name, actually; in this Selenium page object class I would end up with Element, Element, Element redundantly at the end of every single class member.

Of course, I can turn off all the autocompletion, but it would be nice to have a setting to turn off just these naming suggestions in this context while keeping the other autocompletion features.

Environment
  • Windows 10
  • JDK version: 10
  • Visual Studio Code version: 1.22.2
  • Java extension version: 0.3.0
Steps To Reproduce
  1. Use Maven to create a new Java project, using any names and namespaces you prefer.
  2. In your pom.xml file, include these dependencies:
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
        <scope>test</scope>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>3.11.0</version>
    </dependency>
  1. Select the menu File > Preferences > User Snippets.
  2. Select Java.json.
  3. Create this code snippet and save it:
	"Page object element": {
		"prefix": "pageobjectelement",
		"body": [
			"public WebElement ${1:ELEMENTNAME}() {",
			"    return driver.findElementByCssSelector(\"${2:CSSSELECTOR}\");",
			"}"
						],
		"description": "Quick snippet for a new page object element."
	}
  1. Create a new Java class.
  2. In the class, type pageobjectelement and hit Tab to enter the snippet and focus on the first tab stop.
  3. Enter cancelButton and hit Tab to move to the next field.
Current Result

The method name is replaced by cancelButtonElement.

Expected Result

cancelButton remains the name of the method.

Additional Information

(I've been told that the Red Hat extension may be causing this. If this isn't the case, I apologize and hope you can redirect me appropriately.)

@fbricon
Copy link
Collaborator

fbricon commented Apr 18, 2018

Try "java.completion.overwrite":"false". See #462 (comment)

@rlundy
Copy link
Author

rlundy commented Apr 18, 2018

Hi, @fbricon, thank you for the reply. I tried that setting, and I exited and re-ran VS Code just in case it didn't stick or something. Alas, the behavior is the same: As soon as I start typing the method name, VS Code pops up its own naming suggestions, and if I tab away, it plugs in its own over what I typed.

@rlundy
Copy link
Author

rlundy commented Jan 22, 2019

I haven't noticed this behavior in months, so I think either it must've been changed, or I must've lucked into a setting that fixed it.

@rlundy rlundy closed this as completed Jan 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants