Skip to content

Conversation

it6
Copy link
Contributor

@it6 it6 commented Apr 17, 2018

fixes #630

@@ -7,6 +7,7 @@
{ "caption" : "TypeScript: Format Selection", "command": "typescript_format_selection" },
{ "caption" : "TypeScript: Format Document", "command": "typescript_format_document" },
{ "caption" : "TypeScript: Find References", "command": "typescript_find_references" },
{ "caption" : "TypeScript: Code Fixes", "command": "typescript_get_code_fixes" },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TypeScript: Request Code Fixes

response_dict = self.__comm.sendCmdSync(json_str, req_dict["seq"])
return response_dict


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove extra newline

error['end']['offset'] >= column , errors_in_file['body']))
return errors_at_cursor


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove extra newline

column = cursor[1] + 1
if errors_in_file['success']:
errors_at_cursor = list(filter(lambda error:
error['start']['line'] == line and
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stray space

return response_dict


def get_errors_at_cursor(self, path, cursor):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think get_errors_at_cursor should be in service_proxy.py. Also, to me it would make more sense to only request fixes at a position if the plugin has already reported a diagnostic on a given region (so you don't have to send a separate diagnostics request). In other words, I'm not sure requesting a code fix should request diagnostics.

Instead, maybe requesting a code fix at a position should check with the global ProjectErrorListener and see if it's been modified. If so, do nothing, but if not, filter through the errors as you've done here.

Curious to get @billti's thoughts here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After a bit of exploring

Current diagnostics only contain errorMessageString and region leaving out errorCodes and lineOffsets(which are both required arguments to getCodeFixes). I tried passing along errorCodes and offsets but it didn't come out well with existing code structure.

Definitely agree there is a wasted call to server, but for the amount of refactor and existing code base constraints it could be a bigger effort

I updated other things

args = {
"file": path
}
req_dict = self.create_req_dict("semanticDiagnosticsSync", args)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would also have to request syntactic diagnostics.

@DanielRosenwasser
Copy link
Member

DanielRosenwasser commented Apr 19, 2018

Looks sweet! I like how this just applies a quick fix if only one is available. However, I'm getting some strange behavior with carriage returns; notice the CR character:

@it6
Copy link
Contributor Author

it6 commented Apr 19, 2018

Which OS is this? On mac I don't see the CR character. Do you have any setting in sublime to show line ending characters?

I looked at tsc response 'newText': ' bar: any;\n' which is expected with \n at the end not sure how to debug without reproducing it.

If the file doesn't have Unix line endings can you change it and see if that fixes it

@it6
Copy link
Contributor Author

it6 commented Apr 19, 2018

I made a code change to replace CRLF & CR characters to newline characters, please see if that fixes it

@it6
Copy link
Contributor Author

it6 commented Apr 25, 2018

Is there anything else needed for this?

Copy link
Contributor Author

@it6 it6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@stweedie
Copy link

Is there any way this can make it to the released package? It's working well for me when I manually replace the files in the sublime package directory

@stweedie stweedie mentioned this pull request Apr 1, 2019
@pjerem
Copy link

pjerem commented May 22, 2019

Since @DanielRosenwasser review has been take into account, what is blocking this PR to be merged ?

@orta
Copy link
Contributor

orta commented Jul 24, 2019

TBH, looks to me like all feedback is addressed and this PR should be merged 👍

@orta orta merged commit 71612a7 into microsoft:master Jul 24, 2019
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

Successfully merging this pull request may close these issues.

Request to add auto import
5 participants