Sort imports using URI and apply edits using workspace edits#2214
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2214 +/- ##
=========================================
- Coverage 79.84% 75.8% -4.05%
=========================================
Files 310 310
Lines 14359 14407 +48
Branches 2547 2552 +5
=========================================
- Hits 11465 10921 -544
- Misses 2882 3475 +593
+ Partials 12 11 -1
Continue to review full report at Codecov.
|
|
Just needs a rebuild, the Mac agents were updated recently. |
d3r3kk
left a comment
There was a problem hiding this comment.
This change is great, but I think there are some things to resolve:
- CI is failing on helper tests - knock on effect from this change perhaps.
- Fix / add logic surrounding trailing-line hack.
| // We do this to ensure we only run debugger test, as debugger tests are very flaky on CI. | ||
| // So the solution is to run them separately and first on CI. | ||
| const grep = IS_CI_SERVER && IS_CI_SERVER_TEST_DEBUGGER ? 'Debug' : undefined; | ||
| const grep = IS_CI_SERVER && IS_CI_SERVER_TEST_DEBUGGER ? 'Debug' : 'Sortingx'; |
| debugConfigurationRegisterTypes(serviceManager); | ||
| debuggerRegisterTypes(serviceManager); | ||
| appRegisterTypes(serviceManager); | ||
| providersRegisterTypes(serviceManager); |
There was a problem hiding this comment.
I would expect to find all types of providers being registered here (formatProvider, signatureProvider... etc). Is that the intention here?
There was a problem hiding this comment.
DI was added later. So we do not have others registered in the container.
There was a problem hiding this comment.
That is the intention then, good to know.
| return; | ||
| } | ||
|
|
||
| // Hack, if the document doesn't contain an empty line at the end, then add it |
There was a problem hiding this comment.
Is this hack for the 'inner version' of isort only?
If so, I think we should skip this hack for when the settings.isortPath is set to somthing.
Bonus points if we could remove this hack by correcting our inner version of isort.
There was a problem hiding this comment.
Is this hack for the 'inner version' of isort only?
No, we need an empty line for the diff to be genrated correctly.
There was a problem hiding this comment.
Will get removed when we change the diffing coding, there's a separate PR to use an npm package for that.
There was a problem hiding this comment.
Alright, I'll assume we'll rid ourselves of the hack when that #1950 issue is resolved.
| .setup(d => d.activeTextEditor).returns(() => undefined) | ||
| .verifiable(TypeMoq.Times.once()); | ||
| shell | ||
| .setup(s => s.showErrorMessage(TypeMoq.It.isValue('Please open a Python file to sort the imports.'))) |
There was a problem hiding this comment.
I think it would be important to define messages such as this in a common place (used by both the test and the feature itself). That way we can more be more complete and adept at supporting improvements our localization efforts.
There was a problem hiding this comment.
No such functionality available now. Separate PR, we have an issue open for this. I'll try to complete it later.
There was a problem hiding this comment.
Yep, I see it now: #463. I'm glad that we have an issue for it!
| if (!uri) { | ||
| const activeEditor = this.documentManager.activeTextEditor; | ||
| if (!activeEditor || activeEditor.document.languageId !== PYTHON_LANGUAGE) { | ||
| this.shell.showErrorMessage('Please open a Python file to sort the imports.').then(noop, noop); |
There was a problem hiding this comment.
Is there a localization file we can add this string to?
There was a problem hiding this comment.
That will be done in a separate PR (bigger change).
There's a separate task for that.
| shell.verifyAll(); | ||
| documentManager.verifyAll(); | ||
| }); | ||
| test('Ensure empty line is added when line does not end with an empty line', async () => { |
There was a problem hiding this comment.
This test may need some updating, see my comment on the subject of the trailing-line hack.
There was a problem hiding this comment.
This will become unnecessary when we use an npm package to do the diffing. There's an issue for that.
#1950
|
@d3r3kk |
|
Looks good, and for everything I raised we have separate issues tracking them. Now the build just needs to run clean (there are failing tests still). |
|
@DonJayamanne anything holding up merging this? |
487cfa7 to
0fc9e95
Compare
|
Interestingly the tests were successful, however there were issues with the merge and compilation issues. Not sure how the tests ran successfully on CI!!! created PR to resolve merge issues #2508 |
Fixes #2137
Pending manual testing.
"1.2.3", not"^1.2.3")package-lock.jsonhas been regenerated if dependencies have changed