-
Notifications
You must be signed in to change notification settings - Fork 446
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
Fix for indention issue #617
Conversation
Signed-off-by: Sheng Chen <[email protected]>
src/extension.ts
Outdated
let startCharacterNum = changes[0].range.start.character; | ||
let endLineNum = startLineNum; | ||
for (let newText of changes) { | ||
endLineNum += newText.newText.split('\n').length - 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if the line delimiter is \r\n
? The solution is probably platform dependent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, let me change it to split(/\r?\n/)
The PR seems to work as expected so far. Except for the potential line-delimiter issue, my main concern is about the use of seemingly random (it's not) index values while manipulating objects. |
Signed-off-by: Sheng Chen <[email protected]>
Signed-off-by: Sheng Chen <[email protected]>
Signed-off-by: Sheng Chen <[email protected]>
@fbricon Updated the code to support the discontinuous condition. Sometimes the server side may response multiple ranges which are discontinuous. We need to range format each of them separately. |
Testing that fix, I found that formatting with tabs always uses spaces instead. See eclipse-jdtls/eclipse.jdt.ls#775 |
A workaround for issue #557.
For now, just send a range format request after
workspace.applyEdit()
Some GIFs for illustration:
Add unimplemented methods
Extract to local variable
Extract to constant
Extract to method