ci_edit icon indicating copy to clipboard operation
ci_edit copied to clipboard

Autocomplete

Open aaxu opened this issue 8 years ago • 5 comments

Seems like a good feature to have for variable/function names. Maybe one that can be turned off/on.

aaxu avatar Aug 23 '17 00:08 aaxu

Agreed.

The pop-up window that some other editors use can be rather invasive/distracting. I mostly mean when editing existing documents where edits are commonly done in the middle of the document. If I'm just writing to the end of a document then the pop-up doesn't cover the code I'm working on (but I rarely do that, 90%+ of the time I'm editing an existing file).

Can we do something smoother/nicer? I'm not sure what that is yet. Maybe put the suggestions further away or try harder to not cover the work-in-progress. Maybe the text could separate to allow for suggestions while keeping the main document visible.

Also, should we integrate with (an) existing code parser(s) and/or leverage the ci_edit/app/parser.py for suggestions?

dschuyler avatar Aug 23 '17 03:08 dschuyler

That's interesting, because I've just gotten used to the pop-up window and work around it by just exiting it by hand and looking at the code if I need to. This is because usually when I type a variable, I have a name in mind already so I can finish the auto-completion quickly and then resume what I'm working on or just exit and view the code.

I don't really have a great solution that solves every problem, but here are some thoughts:

  • If we put the suggestions far away from the cursor, it may be hassle for the user to move their eyes back and forth. That distance makes it easy to lose track of the cursor and it may take a second or two to resume where you were at.
  • We can put the suggestions above/below/left/right of the cursor. Of these, I think maybe the right of the cursor may be the best since people usually right code at the end of the line? (if they are editing in the middle of the line, then they probably have idea of what variable they want to type out). Blocking the top and bottom of the cursor may cause the user to lose their train of thought in the case that they need to view the section's code and I think the left side of the cursor would just be a bad place to put it. However, overall it's hard to tell without testing it, but these are my general thoughts on them.

It may be good to use an existing one if it provides a wide range of coding language support since there are a lot of rules/syntax we'd have to implement otherwise. Unless the existing ones create a dip in performance, I think it's fine to find one.

aaxu avatar Aug 23 '17 03:08 aaxu

Maybe I should give a pop-up suggestion another try.

External completion/suggestion parsers that I'm aware of are etags and YouCompleteMe. Do you have others in mind?

dschuyler avatar Aug 24 '17 02:08 dschuyler

What about putting the suggestions below by parting the text like this:

232 class Example:
233  def __init__(self):
234    self.cats = 88
235
236  def addCat(|
237
238  def removeCat(self):
239    self.cats -= 1
232 class Example:
233  def __init__(self):
234    self.cats = 88
235
236  def addCat(s|
                self
237
238  def removeCat(self):
239    self.cats -= 1

Hmm, that's not showing what I mean very well without a screen shot. But the screen above doesn't have the suggestion and the lower one does. See a gap parted between lines 236 and 237 without covering any of the document.

dschuyler avatar Aug 24 '17 02:08 dschuyler

I think it's cool but may come to seem annoying. If the options are listed vertically and show 3, 5 or maybe even 10 options, then the code will always be jumping back and forth several lines. We could always make it so that the options are listed horizontally so it just takes up one line, but that may make it harder for readability.

aaxu avatar Aug 24 '17 05:08 aaxu