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

does not replace first character #25

Closed keenahn closed 4 years ago

keenahn commented 5 years ago

MacOs 10.12 SublimeText 3208 TabNine 1.0.14

http://cloud.invisible.email/ea92893ccd42

keenahn commented 5 years ago

Pretty much makes TabNine unusable, which is a damn shame because it's such a great product when it works. Really hoping this is a bug in my sublime configs or something

zxqfl commented 5 years ago

Did this start happening recently?

keenahn commented 5 years ago

Yes, in the last day I think.

Restarting Sublime fixed it (for now).

zxqfl commented 5 years ago

Ok, please let me know if it happens again. I have the same setup myself (with newer version of macOS and older version of Sublime Text) so if we're lucky I'll reproduce it by accident.

Let me know if you find a reliable way of reproducing the issue.

keenahn commented 5 years ago

And it's back :T

Nothing weird that I can see. In sublime's console, I just see tab_nine_substitute

zxqfl commented 5 years ago

I haven't found the cause of your issue, but I added some logic that should help mitigate it. Let me know if it still occurs. (You can make sure you've received the fix by executing Package Control: List Packages and checking that TabNine is v1.0.4.)

keenahn commented 5 years ago

Still happening on TabNine v1.0.5

The behavior has gotten a bit more wacky now. Don't know if this is related or a separate problem (but I have a hunch they're related).

See this gif for a quick example:

Screen Recording 2019-05-31 at 03 39 PM

Hitting tab multiple times gives the first suggestion, followed by the second one (but the first one sticks around)

keenahn commented 5 years ago

FYI, here are my installed packages:

[
        "A File Icon",
        "AceJump",
        "AdvancedNewFile",
        "All Autocomplete",
        "ApplySyntax",
        "AutoFileName",
        "Babel",
        "BeautifyRuby",
        "Better CoffeeScript",
        "BetterFindBuffer",
        "BracketHighlighter",
        "Case Conversion",
        "ColorSchemeEditor",
        "Colorsublime",
        "DA UI",
        "DocBlockr",
        "Dockerfile Syntax Highlighting",
        "Dotfiles Syntax Highlighting",
        "Emoji",
        "Expression",
        "FileClose",
        "FindKeyConflicts",
        "Fix Mac Path",
        "Gist",
        "Git blame",
        "Git Conflict Resolver",
        "GitHub Markdown Snippets",
        "GotoLastEditEnhanced",
        "GotoLineEnhanced",
        "GraphQL",
        "HexViewer",
        "HTML-CSS-JS Prettify",
        "Increment Selection",
        "Indent Respectful Sort",
        "Indent XML",
        "JsPrettier",
        "KeybindingHelper",
        "LESS",
        "Markdown Extended",
        "Markdown Table Formatter",
        "MarkdownEditing",
        "MarkdownPreview",
        "Minifier",
        "Missing Palette Commands",
        "Modific",
        "Monokai JSON+",
        "Neon Color Scheme",
        "Package Control",
        "PackageResourceViewer",
        "PEG.js",
        "Pretty JSON",
        "Pug",
        "QuickSearchEnhanced",
        "RainbowBrackets",
        "Sass",
        "Search in Project",
        "SelectExact",
        "ShellScriptImproved",
        "SideBarEnhancements",
        "SnippetMaker",
        "sql-formatter",
        "SRT",
        "StatusMessage",
        "StringUtilities",
        "StripHTML",
        "SublimeLinter",
        "SublimeLinter-eslint",
        "SublimeLinter-shellcheck",
        "SublimeLinter-tslint",
        "Table Cleaner",
        "TabNine",
        "TabsExtra",
        "Text Pastry",
        "Theme - amCoder",
        "TOML",
        "TypeScript",
        "TypeScript Syntax",
        "WordCount"
    ],

And here's my preferences

{
    "added_words":
    [
        "playbook",
        "handoff",
        "mcy",
        "rebase",
        "downcase",
        "online",
        "audiobook",
        "ebook"
    ],
    "additional_path_items":
    [
        "/Users/keenahn/.nvm/versions/node/default/bin"
    ],
    "always_prompt_for_file_reload": false,
    "always_show_minimap_viewport": false,
    "animation_enabled": true,
    "atomic_save": true,
    "auto_close_tags": true,
    "auto_complete": false,
    "auto_complete_commit_on_tab": false,
    "auto_complete_cycle": false,
    "auto_complete_delay": 0,
    "auto_complete_selector": "meta.tag - punctuation.definition.tag.begin, source - comment - string.quoted.double.block - string.quoted.single.block - string.unquoted.heredoc, text.html.erb ",
    "auto_complete_size_limit": 4194304,
    "auto_complete_triggers":
    [
        {
            "characters": "<",
            "selector": "text.html"
        },
        {
            "characters": ".",
            "selector": "source.js"
        },
        {
            "characters": ".",
            "selector": "source.ts"
        }
    ],
    "auto_complete_with_fields": false,
    "auto_find_in_selection": false,
    "auto_indent": true,
    "auto_match_enabled": true,
    "binary_file_patterns":
    [
        "*.dds",
        "*.eot",
        "*.gif",
        "*.ico",
        "*.jar",
        "*.jpeg",
        "*.jpg",
        "*.pdf",
        "*.png",
        "*.swf",
        "*.tga",
        "*.ttf",
        "*.zip",
        "/private/var/www/vhosts/invisible/shepherd/.cache/**"
    ],
    "bold_folder_labels": true,
    "caret_extra_bottom": 0,
    "caret_extra_top": 0,
    "caret_extra_width": 0,
    "caret_style": "smooth",
    "close_windows_when_empty": false,
    "color_scheme": "Packages/Color Scheme - Wallaby/Neon-KJ.tmTheme",
    "copy_with_empty_selection": false,
    "create_window_at_startup": true,
    "default_encoding": "UTF-8",
    "default_line_ending": "system",
    "detect_indentation": true,
    "dictionary": "Packages/Language - English/en_US.dic",
    "drag_text": true,
    "draw_centered": false,
    "draw_indent_guides": true,
    "draw_minimap_border": false,
    "draw_white_space": "selection",
    "enable_hexadecimal_encoding": true,
    "enable_tab_scrolling": false,
    "enable_telemetry": false,
    "ensure_newline_at_eof_on_save": false,
    "fade_fold_buttons": false,
    "fallback_encoding": "Western (Windows 1252)",
    "file_exclude_patterns":
    [
        "*.pyc",
        "*.pyo",
        "*.exe",
        "*.dll",
        "*.obj",
        "*.o",
        "*.a",
        "*.lib",
        "*.so",
        "*.dylib",
        "*.ncb",
        "*.sdf",
        "*.suo",
        "*.pdb",
        "*.idb",
        ".DS_Store",
        "*.class",
        "*.psd",
        "*.db",
        "*.sublime-workspace"
    ],
    "find_selected_text": true,
    "fold_buttons": true,
    "folder_exclude_patterns":
    [
        ".svn",
        ".git",
        ".hg",
        "CVS"
    ],
    "font_face": "Fira Code Retina",
    "font_options":
    [
        "dlig"
    ],
    "font_size": 12,
    "gpu_window_buffer": "auto",
    "gutter": true,
    "highlight_line": true,
    "highlight_modified_tabs": true,
    "hot_exit": true,
    "ignored_packages":
    [
        "Vintage"
    ],
    "indent_guide_options":
    [
        "draw_normal",
        "draw_active"
    ],
    "indent_subsequent_lines": true,
    "indent_to_bracket": false,
    "index_exclude_patterns":
    [
        "*.log"
    ],
    "index_files": true,
    "index_workers": 0,
    "line_numbers": true,
    "line_padding_bottom": 0,
    "line_padding_top": 0,
    "margin": 0,
    "match_brackets": true,
    "match_brackets_angle": false,
    "match_brackets_braces": true,
    "match_brackets_content": true,
    "match_brackets_square": true,
    "match_selection": true,
    "match_tags": true,
    "move_to_limit_on_up_down": false,
    "new_file_syntax": "MarkdownEditing/Markdown",
    "open_files_in_new_window": false,
    "overlay_scroll_bars": "system",
    "preview_on_click": true,
    "remember_open_files": true,
    "rulers":
    [
        80,
        100,
        120
    ],
    "save_on_focus_lost": false,
    "scroll_past_end": true,
    "scroll_speed": 1.5,
    "shift_tab_unindent": false,
    "show_definitions": false,
    "show_encoding": true,
    "show_errors_inline": true,
    "show_full_path": true,
    "show_line_endings": false,
    "show_panel_on_build": true,
    "show_tab_close_buttons": false,
    "smart_indent": true,
    "spell_check": false,
    "spelling_selector": "markup.raw, source string.quoted - punctuation - meta.preprocessor.c.include, source comment - source comment.block.preprocessor, -(source, constant, keyword, storage, support, variable, markup.underline.link, meta.tag)",
    "tab_completion": true,
    "tab_size": 2,
    "theme": "amCoder.sublime-theme",
    "theme_font_options":
    {
    },
    "translate_tabs_to_spaces": true,
    "tree_animation_enabled": false,
    "trim_automatic_white_space": true,
    "trim_trailing_white_space_on_save": true,
    "use_simple_full_screen": false,
    "use_tab_stops": true,
    "word_separators": "./\\()\"'-:,.;<>~!@#$%^&*|+=[]{}`~?",
    "word_wrap": true,
    "wrap_width": 0
}
keenahn commented 5 years ago

OK I found something. If I set "tab_completion": false, in my preferences, it seems to work. So I suppose it's a weird interaction with Sublime's default auto complete?

keenahn commented 5 years ago

OK nm, that didn't fix it. This is a real stumper :t

zxqfl commented 5 years ago

I agree that it is probably the same underlying issue -- I think the selection is later in the file than TabNine expects. If TabNine is expecting to replace fi with findUser, it would previously delete the 2 characters before the cursor and replace them with findUser. If the selection is later than TabNine expects, this won't delete the fi, and it could lead to your original problem.

In the patch, I made TabNine check whether the text before the cursor is what it was expecting, and if not it falls back to replacing the word before the cursor. This might explain the new behaviour you're seeing -- my guess is that if you open the developer console with Ctrl+`, you'll see something like: TabNine expected prefix "fi" but found prefix " ", falling back to replacing ""

Since I can't reproduce the issue, it's probably caused by an interaction with one of your other installed plugins. Your indentation plugins are prime candidates, since they might bind commands to Tab. Can you try going to Sublime Text -> Preferences -> Package Settings -> TabNine -> Key Bindings (User) and adding the following?

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

This will let you use / instead of Tab to accept completions. Let me know if the same issue occurs when you accept a completion using /.

keenahn commented 5 years ago

Same issue occurs when I switch to using / as the leader key. Also disabled all plugins (i believe) that could interact with the Tab key or indenting or moving the cursor

Getting reallllly weird behavior now on repeated tabs. It's like it doesn't know where to properly move the cursor. Should I try downgrading Sublime to a previous version?

This only happens after the editor has been open for a while. On restart, it's fine.

Screen Recording 2019-06-06 at 10 57 PM

keenahn commented 5 years ago

Don't know if this helps, but when I'm experiencing the bug, sometimes I'll move the cursor to an empty spot, and I'll see the predictions for the last thing I was typing.

keenahn commented 5 years ago

Still happening. Any thoughts?

keenahn commented 4 years ago

Can close this now as it seems all good :)