vknabel / vscode-swift-development-environment

New home of Swift Development Environment for VS Code
https://marketplace.visualstudio.com/items?itemName=vknabel.vscode-swift-development-environment
Apache License 2.0
175 stars 14 forks source link

Class function autocomplete #9

Closed LinusU closed 6 years ago

LinusU commented 6 years ago

When accepting autocomplete for an override function, the func keyword gets added twice, resulting in broken code.

e.g. with this code:

class Foobar: UIViewController {
  func vie
}

and having the cursor after func vie and choosing viewDidAppear(_ animated: Bool) results in the following code:

class Foobar: UIViewController {
    func override func viewDidAppear(_ animated: Bool) {

    }
}
vknabel commented 6 years ago

@LinusU Thanks for your feedback. I had a deeper look on that, but it does not seem to be fixed as easy as initially thought.

Details: According to SourceKit/docs/Procol#code-completion, I just need to pass SourceKit's key.num_bytes_to_erase to vscode-languageserver's CompletionItem.additionalTextEdits as TextEdit.del, but in reality key.num_bytes_to_erase is always 0. Maybe I misunderstood something?

rudedogg commented 6 years ago

I also get multiple dots (.) when accepting a completion. I wonder if it's the same issue?

vknabel commented 6 years ago

@rudedogg Probably yes. Can you provide some example code where it happened to you? Are you a Mac or a Linux user?

LinusU commented 6 years ago

@vknabel is this fixed? In which version? I would love to test it out ☺️

vknabel commented 6 years ago

@LinusU no sorry. I accidentially Hit the wrong Button πŸ™ˆ

LinusU commented 6 years ago

Hehe, I almost guessed that πŸ˜„ no problem!

rudedogg commented 6 years ago

Hey @vknabel, can you try this:

screen shot 2018-03-17 at 8 06 49 pm

[Press Enter for the completion]

screen shot 2018-03-17 at 8 07 24 pm

Let me know if you can reproduce, if not I'll find try and replicate it on the GitHawk iOS project or something.

vknabel commented 6 years ago

@LinusU here is another build. It should fix your func issue. @rudedogg I still couldn't reproduce it and I guess this may be related to a different setup, because @renanyoy did have this problem a while back, too. I included a workaround that hopefully fixes your .. issue, too.

vscode-swift-development-environment-2.3.0.vsix.zip also includes #10 and #11.

rudedogg commented 6 years ago

@vknabel Sorry for the really late reply. Electron apps are laggy for some reason on my Hackintosh, but new graphics drivers were released so VS Code is running a lot better.

I tried the 2.3.0 VSIX release you linked, and it fixes the double dot (..) issue when accepting a completion candidate πŸŽ‰ !

In case it helps debug that issue, here's my setup: macOS 10.13.4, VS Code 1.21.1, project targeting macOS 10.10 (https://github.com/akhilcb/ACBTokenField)

vknabel commented 6 years ago

@rudedogg great to hear! And as it solved your issues: I just released 2.3.0.