codota / tabnine-sublime

Tabnine Autocomplete AI: JavaScript, Python, TypeScript, PHP, C/C++, HTML/CSS, Go, Java, Ruby, C#, Rust, SQL, Bash, Kotlin, Julia, Lua, OCaml, Perl, Haskell, React
https://www.tabnine.com/install/sublime
MIT License
194 stars 36 forks source link

Autocompleting without hitting Tab #63

Closed IPWright83 closed 4 years ago

IPWright83 commented 4 years ago

Is there a way to stop this behaviour? I want TabNine as an extra feature to use, not something that gets in the way of typing.

Peek 2020-07-03 19-46

amircodota commented 4 years ago

@IPWright83 This sounds like a bug to me. Tabnine should only ever complete when you hit tab.

IPWright83 commented 4 years ago

@amircodota thanks, if there's any more info I can provide let me know.

IPWright83 commented 4 years ago

Are there any notes on how you can run TabNine with some more debugging? I keep turning it on wanting to use it more, but everytime I hit this bug (which is quite frequently) I unfortunately have to abandon it as it's almost impossible to workaround properly.

amircodota commented 4 years ago

@IPWright83 you can try debugging the plugin yourself, if you have the time. We would certainly appreciate it :-)

I can provide setup instructions, if you want to go down that path

IPWright83 commented 4 years ago

Yeah, that'd be good if you don't mind. I'm not a Python dev but I'm sure if I can add a breakpoint somehow and do some debugging I've got a fighting chance of working out what's happenning.

amircodota commented 4 years ago

I added a page to the wiki.

This is an initial version of the page, so any feedback on it is also welcome.

Good luck

IPWright83 commented 4 years ago

@amircodota ok so here's an example that's auto completing without me hitting Tab.

image

If I press g then that'll auto complete to the first suggested result (which might be ok in this instance - but obviously sometimes the behaviour gets in the way).

I added logging of the command_name and the insertion event and I can see the following happens:

tab_nine_leader_key Inserting completion tab_nine_substitute

So whatever the tab_nine_leader_key is, I'm guessing is triggering this to occur.

IPWright83 commented 4 years ago

Hmm, I can see this defined in the default key mapping - however it's definitely not tab that I'm pressing.

{ "keys": ["tab"], "command": "tab_nine_leader_key", "context": [ { "key": "tab_nine_leader_key_available", "operator": "equal", "operand": true }] },

Just to provide some evidence for that I've enabled the sublime.log_input(True) flag. This is the output I got:

chr evt: c (0x63)
chr evt: o (0x6f)
chr evt: n (0x6e)
chr evt: s (0x73)
chr evt: t (0x74)
chr evt:   (0x20)
chr evt: s (0x73)
chr evt: e (0x65)
chr evt: t (0x74)
chr evt: T (0x54)
chr evt: a (0x61)
chr evt: g (0x67)
tab_nine_leader_key
tab_nine_substitute
amircodota commented 4 years ago

@IPWright83 Any chance you have another plugin or something that changes the key bindings, like vim key bindings or something like that?

IPWright83 commented 4 years ago

@amircodota not that I'm aware of - I've just tried disabling a bunch a few of the bigger ones and it seems to still behave that way.

I've got a bunch of keybindings myself, but nothing that I think should inteferre:

[
    { "keys": ["ctrl+d"], "command": "run_macro_file", "args": {"file": "res://Packages/Default/Delete Line.sublime-macro"} },
    { "keys": ["ctrl+shift+r"], "command": "reindent" , "args": { "single_line": false } },
    { "keys": ["ctrl+alt+p"], "command": "prompt_select_workspace" },
    { "keys": ["ctrl+alt+left"], "command": "jump_back" },
    { "keys": ["ctrl+alt+right"], "command": "jump_forward" },
    { "keys": ["ctrl+alt+d"], "command": "git_gutter_diff_popup" },
    { "keys": ["ctrl+alt+s"], "command": "gs_show_status" },
    { "keys": ["alt+up"], "command": "git_gutter_next_change" },
    { "keys": ["alt+down"], "command": "git_gutter_prev_change" },
    {
        "keys": ["g"],
        "command": "gs_custom",
        "args": {
            "args": ["pull"],
            "output_to_panel": true,
            "start_msg": "Starting pull",
            "complete_msg": "Pull complete.",
        },
        "context": [
            { "key": "setting.command_mode", "operator": "equal", "operand": false },
            { "key": "setting.git_savvy.status_view", "operator": "equal", "operand": true },
        ]
    },
    { "keys": ["ctrl+alt+f"], "command": "find_results_buffer_utils", "args": {"action": "focus_buffer"}, "context": [{"key": "is_find_results_buffer_open"}] },
    { "keys": ["ctrl+shift+p"], "command": "show_overlay", "args": {"overlay": "command_palette"} },
    { "keys": ["ctrl+shift+."], "command": "show_overlay", "args": {"overlay": "command_palette"} },
]
amircodota commented 4 years ago

@IPWright83 Can you send a list of all sublime packages you have installed?

IPWright83 commented 4 years ago

@amircodota sure, didn't realise these were easy to get at:

"A File Icon",
"Babel",
"BetterFindBuffer",
"CFML",
"CloudFormation Validation",
"DiffTabs",
"DocBlockr",
"Dockerfile Syntax Highlighting",
"FindResultsBufferUtils",
"Floobits",
"Git Conflict Resolver",
"GitGutter",
"GitSavvy",
"JsPrettier",
"LESS",
"Less2Css",
"Package Control",
"PackageResourceViewer",
"SublimeLinter",
"SublimeLinter-contrib-xo",
"SublimeLinter-contrib-yamllint",
"SublimeLinter-eslint",
"SublimeLinter-json",
"SyncedSideBar",
"TabNine",
"Text Pastry",
"Theme - Soda",
"TodoReview",
"TypeScript",
"TypeScript Syntax",
"WordHighlight"
IPWright83 commented 4 years ago

@amircodota well, that was interesting...

I've been looking at the other GitHub issue about remapping the shortcut key so it doesn't interfere with snippets which is a real pain. So opened my settings and saw this:

{ "keys": ["g"], "command": "tab_nine_leader_key", "context": [ { "key": "tab_nine_leader_key_available", "operator": "equal", "operand": true }] }

I have no idea how that got there (I don't remember ever setting it + have re-installed the package), but I believe that explains all the weirdness going on!

amircodota commented 4 years ago

Glad you were able to figure it out :+1:

IPWright83 commented 4 years ago

Thanks @amircodota - sorry to have wasted some of your time, but I appreciate the help in debugging as I would never have thought to look in there (on the basis I thought I'd never changed it!).