Skip to content
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

company-mode off-by-one error regarding prefix length in dap-ui-repl #769

Open
doeblerh opened this issue Jan 1, 2024 · 0 comments
Open

Comments

@doeblerh
Copy link

doeblerh commented Jan 1, 2024

When using dap-ui-repl-mode for python debugging with debugpy, the last character entered is ignored in filtering the completion candidates. For example, when debugging

class C:
    def __init__(self):
        self.abcdx = 1
        self.abcex = 2

c = C()
# breakpoint here!

and entering dap-ui-repl, I get

>> c.abcd[CURSOR HERE]
    |abcdx field|
    |abcex field|

but

>> c.abcdE[CURSOR HERE]
    |abcdx field|

So it seems as if the prefix that is extracted and used for completion candidate computation is missing the last character entered.

To reproduce, install emacs 27.1, a plain spacemacs (select vim style keybindings, i.e. evil), add layers

     dap
     (python :variables
             python-backend 'lsp
             python-lsp-server 'pyright
             python-formatter 'black
             python-format-on-save t
             )

and debug the above python code using M-x dap-debug -> "Python :: Run file (buffer)"

I am currently using as workaround a patched version of dap-ui-repl--calculate-candidates, where I add 1 to the column specified in dap-ui.el, i.e., i replaced the corresponding line with

  :column (1+ (- (length text) (- (point-at-eol) (point))))))

which fixes completion to behave as expected.

However, since this is the only scenario in which I use dap-ui-repl, I cannot check or tell if this change breaks completion under different conditions. Maybe, it is evil-related?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant