dotBunny / VSCode

Unity Visual Studio Code Integration
MIT License
674 stars 181 forks source link

Script opens but only to a blank line number. #107

Closed Shaba1 closed 8 years ago

Shaba1 commented 8 years ago

I installed the VSCode addon for unity into a project that I already was working on. That ended up being a disaster. After 10 days and using a blank text project . I figured out that in unity's preferences vscode tab where you have to put in the bath to vscode you put in the path to code.cmd rather then the exe. Anyway.

I can finally see a a script's text in the inspector now.( that was not happening before) but when I click the open button for the script VSCode come up with a two panes. One list the project's name the other list the script's name but only have a line #1 and no script code. I can see the code in the inspector panel though. Can someone tell me what is going wrong>

ghost commented 8 years ago

Hello. Can you please provide some screenshots? Did you tried the latest version of the plugin?

Shaba1 commented 8 years ago

i downloaded the zip directly from here at github 3 weeks ago.

Here are some screen shots: They are

1 a screen shot of the vscode plugin in the unity editor

2 a script that I got off the unity forum just to test out editing with vscode and the plugin. NOT something I am actually going to run or use in a project right now. Shown in the unity inspector..

3 The unity editor perferences.

4 the VSCode plugin 'tab' of the unity editor preferences

5 What pops up when I click the open button in the inspector on that script. As you can see it opens two window on with the name of the project and one with the name of the script but with no code in it.

6 A VScode window that comes up AFTER I shut unity down and double click the vscode icon on my desktop and go to the folder and open that same script within vscode. Now all the code in the script shows up and i can edit it if I want.

open in vscode

vscode version open script

editor preferences

vscode tab manually open

Shaba1 commented 8 years ago

These screen shots are displayed in the wrong order but this sites software. Not the order I dragged and dropped them in. Sorry.

ghost commented 8 years ago

No prob. I guess you're on Windows (the "C:..." path in the Preferences tab and the CRLF for line endings in VSCode). A fix to path issues was merged recently, a bug which replaced spaces with "\ " on a non-unix environment, but on your first screenshot I see "[...]Blender\ Files/[...]" so this screenshot is from before this patch. Escaping spaces on a Windows machine may cause the correct folder not being found and vscode displaying a empty new file, so that could be your problem. Could you please try it with the latest plugin?

Shaba1 commented 8 years ago

I just download the zip from this site. The site says the plugin was updated 10 days ago so that would be June 2nd 2106. I have copied and pasted the plugins folder over top of the present one in that same project. I will get back to you in about 10 minutes to see if this solves the problem.

capture_001_12062016_220645

ghost commented 8 years ago

So, any results so far?

Shaba1 commented 8 years ago

As I said I re dowloaded it from the get hub page and installed it and get the same resurl

ghost commented 8 years ago

That's weird. Based on the #1 screenshot, looks like the problem I said. Could you please try using it on a brand new project (the project's path should not have spaces)? It will take no longer than 2 minutes. Thanks in advance.

Shaba1 commented 8 years ago

Ok spaces in the path seem to be the issue. I just made the exact same type of project but instead put it on my desktop rather in the C:\Users\DD\Desktop\Blender Files\Unity Sites\vscodetest\ directory.. Same exact type of test project is now in C:\Users\DD\Desktop\vscodetest\ directory and that script opens in vsccode with no problems. I hate to clutter up my desktop or keep thing in the root directory but i can adjust. Thanks. But this might be something you want to look into. Obviouly the plugin is having problems with spaces in a pathname at least on windows.

Obtw msqes thanks for the help. I will just make a unityfiles folder on my desktop so there is not spaces in the path name for now until you get this bug fixed. Once again thanks for the help. I know it probably was not easy helping a rank newbie like me.

ghost commented 8 years ago

No problem, man, I thought this bug was fixed but seems not. Anyway, I'll see what's wrong, good luck with your project. See 'ya

rodrigodzf commented 8 years ago

I fixed this issue at least for osx and vscode 1.2.1 #109

ghost commented 8 years ago

Looking on the source code, there's no call for EscapePathSpaces on Windows, so it couldn't happen, which is kinda weird. Since this specific problem was fixed on #105 , this issue can be closed, @reapazor .

Shaba1 commented 8 years ago

mseqs said: 'Looking on the source code, there's no call for EscapePathSpaces on Windows, so it couldn't happen, which is kinda weird. Since this specific problem was fixed on #105 , this issue can be closed, @reapazor "

Sorry to show my ignorance But i did not understand what you said there mseqs . For right now i just moved the Unity Sites folder to my desktop and renamed it to UnitySites so there is no spaces in the path name. That seems to solved my problem for now. I just do not like it when things do not work as they are supposed to. Even though I found a workaround is this problem still being worked on so that when windows people that download the plugin directly from here on gethub rather then using a cvs program do not run into it?

ghost commented 8 years ago

EscapePathSpaces changes " " to "\ ", which is your problem in the first screenshot (see the path), but there is no call to this function if it's on Windows (actually, this function is not needed anywhere). Your problem was only solved when you changed the project to a path with no spaces, even the plugin not escaping the spaces (in theory), which is weird.

I made a pull request which removed this function for all platforms, but it was not merged yet (don't know why, no problems/errors appeared with the changes). If this problem persists, we need to find where the bug is, but I don't have a Windows machine for further testing.

The plugin (as far as I know) have a auto-update feature, so you can update it without the need to download it from github. The plugin is available and is updated from github, so downloading it from here (or updating it from unity's editor) makes no difference at all.