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

Code Actions problems #47

Closed
daliusd opened this issue Nov 10, 2020 · 3 comments
Closed

Code Actions problems #47

daliusd opened this issue Nov 10, 2020 · 3 comments

Comments

@daliusd
Copy link
Contributor

daliusd commented Nov 10, 2020

I'm experimenting with LSP Code Actions in Ale and one person suggested that jedi-language-server is good candidate for testing code actions. However I usually get quite not perfect results with it. Let's say I have following python file:

def main():
    a = 1
    b = 2
    c = a + b

I give instructions to extract function for code starting with line a = 1 and ending with last line. The result is following (notice that return is in wrong line):


def func_dfouerpw():
    a = 1
    b = 2
    c = a + b    return c


def main():
    c = func_dfouerpw()

Here is JSON (vimscript format) that I get from jedi-language-server:

{'id': 7, 'jsonrpc': '2.0', 'result': [{'diagnostics': v:null, 'edit': {'changes': v:null, 'documentChanges': [{'edits': [{'range': {'end': {'character': 7, 'line': 1}, 'start': {'character': 4, 'line': 1}}, 'newText': 'fu'}, {'range': {'end': {'character': 8, 'line': 1}, 'start': {'character': 8, 'line': 1}}, 'newText': 'c_dfouerpw'}, {'range': {'end': {'character': 14, 'line': 4}, 'start': {'character': 14, 'line': 4}}, 'newText': '    return c^@^@^@def main():^@    c = func_dfouerpw()^@'}], 'textDocument': {'uri': 'file:///Users/daliusd/projects/photoscripts/test.py', 'version': v:null}}]}, 'kind': 'refactor.extract', 'title': 'Extract expression into function ''func_dfouerpw''', 'command': v:null}]}

I have not tested jedi-language-server with other LSP implementations but could it be that there is problem in jedi-language-server side.

@daliusd
Copy link
Contributor Author

daliusd commented Nov 11, 2020

I think problem is in out side. It looks like existing code is ignoring existing end-of-lines.

@daliusd daliusd closed this as completed Nov 11, 2020
@pappasam
Copy link
Owner

pappasam commented Nov 11, 2020

@daliusd great, thanks! And please let me know if you discover that it is, in fact, a problem with jedi-language-server. I'd definitely want to fix that if it were that case. Note that, when trying your example above, things work correctly with coc.nvim, producing:

def func_thoqdjlj():
    a = 1
    b = 2
    c = a + b
    return c


def main():
    c = func_thoqdjlj()

@daliusd
Copy link
Contributor Author

daliusd commented Nov 12, 2020

Hey, thanks for confirming it. It was problem in Ale's code and I hope I have fixed it. I will ask people to do more testing and let's see what will happen 😀

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

2 participants