liamcain / AutoFileName

Sublime Text plugin that autocompletes filenames
515 stars 78 forks source link

First path component in a string does not trigger suggestions when using snippet #28

Closed rchl closed 11 years ago

rchl commented 11 years ago

I use the plugin to autocomplete #include paths in c++ code.

SublimeText has a "inc" snippet that inserts #include "|" automatically (with cursor in the position of | character). Plugin is not triggering suggestions box until I write "/". It works if write that snippet manually.

liamcain commented 11 years ago

Okay, so I went to quickly try to reproduce the bug and I'm experiencing something different. AutoFileName is automatically inserting a filename from the current directory into the include. Obviously that is not the correct behavior either so I'll look more into this later. Thanks for the report.

rchl commented 11 years ago

Well, for me personally that feature (of inserting corresponding header path) is useless as I need to insert full paths relative to my root directory but I don't think it's wrong. It does not get in a way, anyways, as one can just start typing and overwrite that.

But ignoring that, can you reproduce the bug I've filed? Just start overwriting what is auto inserted there.

rchl commented 11 years ago

And it's probably part of the snippet itself?

liamcain commented 11 years ago

Yeah, you're right. The inserting of the filename is part of the snippet. But if I type over the insert path, I get the files as expected. Maybe it's something settings related.

rchl commented 11 years ago

I'm using Sublime3 BTW (if it makes a difference). I'll try to debug this as I can reproduce. I guess there could be plugins conflict or something.

rchl commented 11 years ago

It seems like it could just be Sublime's behavior. As I don't press any key (ctrl+space, for example) to trigger suggestions, I just need to rely on on_query_completions being called. But it's not called on overwriting auto inserted path. So probably nothing you could do in the plugin (in a clean way at least).

liamcain commented 11 years ago

I know it has been awhile but I'm making some updates to my plugins and have been able to reproduce this bug on Windows. Surprisingly, it worked as expected on OS X. I'll look more into this and hopefully come up with a solution.

liamcain commented 11 years ago

Oh... I figured it out. It's actually quite simple and not really a bug at all. Since I've been using pretty much the default settings for Windows and haven't transferred over my user preferences yet, I discovered what the issue is. The #include snippet uses 2 fields. By default ST won't autocomplete when within fields. On my OS X machines I have "auto_complete_with_fields": true so that's why I didn't notice the situation. Adding that to your user prefs will fix the issue. Or you can just press esc to get out of the fields.

rchl commented 11 years ago

Oh, nice.

I think enabling this pref might have some annoying adverse effects so probably the best option for me is to override this snippet with one that uses ${0} only. Thanks for finding that out.