-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
PR: Fix completions bug in Kite introduced by PR 10605 #10630
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
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,6 +28,9 @@ | |
| rtree_available = False | ||
|
|
||
| # Local imports | ||
| from spyder.plugins.completion.languageserver import ( | ||
| LSPRequestTypes, CompletionItemKind) | ||
| from spyder.plugins.completion.kite.providers.document import KITE_COMPLETION | ||
| from spyder.py3compat import PY2 | ||
| from spyder.config.manager import CONF | ||
|
|
||
|
|
@@ -764,6 +767,51 @@ def test_fallback_completions(fallback_codeeditor, qtbot): | |
| code_editor.toggle_code_snippets(True) | ||
|
|
||
|
|
||
| @pytest.mark.slow | ||
| @pytest.mark.first | ||
| @flaky(max_runs=5) | ||
| def test_kite_textEdit_completions(mock_codeeditor, qtbot): | ||
|
metalogical marked this conversation as resolved.
Outdated
|
||
| """Test on-the-fly completions.""" | ||
|
metalogical marked this conversation as resolved.
Outdated
|
||
| code_editor, mock = mock_codeeditor | ||
|
metalogical marked this conversation as resolved.
Outdated
|
||
| completion = code_editor.completion_widget | ||
|
|
||
| code_editor.toggle_automatic_completions(False) | ||
| code_editor.toggle_code_snippets(False) | ||
|
|
||
| # Set cursor to start | ||
| code_editor.go_to_line(1) | ||
|
|
||
| qtbot.keyClicks(code_editor, 'my_dict.') | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The reason I use this test case is because this is a type of completion that Kite returns (it allows users to quickly access dict keys with a
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I didn't know that and it's pretty cool! |
||
|
|
||
| # Complete f -> from | ||
|
metalogical marked this conversation as resolved.
Outdated
|
||
| mock.side_effect = lambda lang, method, params: {'params': [{ | ||
| 'kind': CompletionItemKind.TEXT, | ||
| 'label': '["dict-key"]', | ||
| 'textEdit': { | ||
| 'newText': '["dict-key"]', | ||
| 'range': { | ||
| 'start': 7, | ||
| 'end': 8, | ||
| }, | ||
| }, | ||
| 'filterText': '', | ||
| 'sortText': '', | ||
| 'documentation': '', | ||
| 'provider': KITE_COMPLETION, | ||
| }]} if method == LSPRequestTypes.DOCUMENT_COMPLETION else None | ||
| with qtbot.waitSignal(completion.sig_show_completions, | ||
| timeout=10000) as sig: | ||
| qtbot.keyPress(code_editor, Qt.Key_Tab, delay=300) | ||
| mock.side_effect = None | ||
|
|
||
| assert '["dict-key"]' in [x['label'] for x in sig.args[0]] | ||
| qtbot.keyPress(code_editor, Qt.Key_Enter, delay=300) | ||
| assert code_editor.toPlainText() == 'my_dict["dict-key"]\n' | ||
|
|
||
| code_editor.toggle_automatic_completions(True) | ||
| code_editor.toggle_code_snippets(True) | ||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| pytest.main(['test_introspection.py', '--run-slow']) | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.