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

inserting method from autocomplete doesn't place cursor correctly #31

Closed
SlimeQ opened this issue Jan 18, 2016 · 5 comments
Closed

inserting method from autocomplete doesn't place cursor correctly #31

SlimeQ opened this issue Jan 18, 2016 · 5 comments

Comments

@SlimeQ
Copy link
Contributor

SlimeQ commented Jan 18, 2016

when an autocomplete option is chosen, the cursor becomes invisible and the parameter class names are inserted (eg; java.lang.String). the cursor position stays where it was when enter was pressed. the expected behavior, imo, would be to place the cursor in the parameter field and be able to tab between them as if it were a snippet
screenshot from 2016-01-18 13 46 32

@keskiju
Copy link
Owner

keskiju commented Jan 18, 2016

Yes, you can tab through variable name and parameters using tab. The cursor is not placed at the first parameter because after examining methods of a class, you are likely to change the class name to a variable name first and only then fill the parameters. e.g

CoreEntity.sortDescBy(java.lang.String)

becomes

myEntity.sortDescBy("some string");

But on my editor cursor does not stay where enter was pressed. The class name (here CoreEntity) becomes selected automatically so that I can replace it, and after that I can cycle through all parameters using tab replacing them also.

@SlimeQ
Copy link
Contributor Author

SlimeQ commented Jan 18, 2016

ah, yeah upon further inspection i can tab through the fields. however the first field selected in that example is CoreEntity and i have to press tab to switch to java.lang.String. false alarm. it just occurred to me that the package only works on class names because variable names don't get registered to the proper type. this behavior makes sense now.

it would be neat if variable names could get resolved to classes, however. should be possible with a clever regex routine. if i were to try to implement this where would i find the hook that generates autocomplete possibilities for a given variable?

@keskiju
Copy link
Owner

keskiju commented Jan 18, 2016

Check issue #8. It already resolves a variable name to a class in some cases. You can see this in action in the preview animation shown on readme,md. But it's still a really quick hack so by all means improve it, if you like. You can see these TODO comments there:

    // Find class name by a variable name given as prefix
    // TODO traverse brackets backwards to match correct scope (with regexp)
    // TODO handle 'this.varName' correctly

@keskiju
Copy link
Owner

keskiju commented Jan 18, 2016

Currently it seeks variable declaration from previous 10 rows:

editor.getTextInRange([[bufferPosition.row - 10, 0], bufferPosition]),

Just remove that and include some bracket matching to the regex and it should work much better already.

@keskiju
Copy link
Owner

keskiju commented Jan 18, 2016

And also scopeDescriptor mentioned in issue #8 might provide some useful information about current scope.

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