-
Notifications
You must be signed in to change notification settings - Fork 52
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
Add async mode #58
base: master
Are you sure you want to change the base?
Add async mode #58
Conversation
* remove company-tabnine--response, add company-tabnine--response-cache and company-tabnine--response-cache. * add show-user-message option. * add company-tabnine-max-request-buffer option. * add buffer name in process. * move company-tabnine-kill-process to interactive part. * rewrite company-tabnine--decode to accept multiline inputs. * remove 'stop symbol in company-tabnine--prefix
I guess that you @karta0807913 forgot to add @TommyX12 as a reviewer in this pr and therefore he might not get notified for this pr. |
Thanks for the change. When I tested it out, it seems like sometimes the completion candidates will glitch out, sometimes having “??” appearing inside the text. Not sure if it’s a problem only on my machine; could you also reproduce the issue? I’m using Emacs 27.2 on Apple M1. |
@TommyX12 You can use the following code to reproduce this problem. (defun company-test (command &rest args)
(interactive (list 'interactive))
(cl-case command
(interactive (company-begin-backend 'company-test))
(prefix '("T" . t))
(candidates (list (concat "AB" (propertize "E" 'display "¬") "CD") ;; display property works.
(concat "AB" (propertize "\\n" 'display "¬") "CD") ;; display property works.
(concat "AB" (propertize "\n" 'display "¬") "CD") ;; display property not working :(
(concat (propertize "A\n" 'display "A¬B¬C") ))))) ;; display property not working :( I think I will create a new issue in |
@dmorady1 thank you for replay. |
That should explain the “??” Character showing up; though sometimes even without “??”, the completion candidates become glitched, particularly when I type slowly. In my experience this happened while editing a file that is saved to disk. Let me know if you can reproduce this issue as well. |
@TommyX12 I am little bit confuse. |
My tabnine settings is to show 5 completion candidates, but in the image, there's clearly more candidates than it should be. All the candidates after the fifth one are not supposed to be there. Also, their text are wrong: there shouldn't be 4 newlines in the completed text. |
@TommyX12 that because the result of the last prediction has been cached. For example, when you are inserting "This is a[n]" ([] is the cursor). Since the result from the Tabnine server or your local network is delayed, the programmer cannot get the result immediately. However, the programmer can keep inserting the result. To solve this problem, when the predicted data is back, my implementation compares results from Tabnine and the current text to see if the prediction is correct. For example (if the candidate is 3): Prediction table:
Therefore, the prediction Prediction table:
That's why you see the candidates are more than 3.
Of course, I can delete or change this feature if you don't like it. We can use some algorithm that changes the mechanism to make the numbers of candidates always is fixed. For example, we can use the length, confidence, and age of the candidate to filter and make sure the result is sensible.
Unfortunately, this is the actual result of Tabnine. :( |
Hi @karta0807913, thank you for your work! I tried your branch, and unfortunately I'm finding that asynchronous mode works worse than the current version in this repository. As a test, I'm trying the following Python file: import numpy as np
ML_LABELS = np.array([
[1, 1, 0, 0, 0],
[1, 0, 0, 0, 0],
[1, 0, 1, 0, 0],
[1, 0, 1, 1, 0],
[1, 0, 1, 1, 1],
])
# Transpose ML_LABELS
b = (point is at the end, after With the old non-asynchronous version, I can invoke With your branch, I have to invoke Hope you find this feedback helpful! |
Hello @CyberShadow, In the old non-asynchronous version, the user gets a huge delay when calling In this version, I want to improve users experience when they want to predict when they are typing. So I did the change I mentioned before. In my changes, I send a request to the company server and return the function call right away. Then use the user input between this and previous call to filter out these outdated result which predict incorrectly. If you have a better idea, please tell me! |
Have you considered using company's built-in support for asynchronous backends? https://www.badykov.com/emacs/async-company-mode-backend/ I see there is some commented-out code in this direction: company-tabnine/company-tabnine.el Lines 694 to 696 in 98e9e8b
|
I want to implement the current mistakes:
company-tabnine-wait
is too small, the result from tabnine will be dropped.company-tabnine-wait
is too big, some old computers (like mine) are slow when typing.company-tabnine--process-filter
cannot parse output from the process correctly.and company-tabnine--response-cache.