-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Monkeypatch ternServer.normalizeFilename so it doesn't break Mac/Linu… #12734
Conversation
On OSX Do you think we should file an issue upstream? |
By the way, how do you discovered this? And should we replace |
ping @marijnh any advice on this? |
Diabling normalizing of filenames will definitely break several aspects of Tern. I couldn't find out, from this issue, why you'd want to do that. |
Yes, I think we should change the two leftover I'll file an issue over at Tern, even though I'm not sure this is an issue that many face. I also have a simple fix in mind. |
Oh, didn't think you, @marijnh, would actually look at this issue, heh. Notice also that everything worked fine until ternjs/tern@24044a4, which was part of our recent Tern (and Acorn) update. What issues can such a change cause? I could think of requesting the same file two times (once with the absolute and once with the relative path), but that shouldn't cause too much trouble. The fix I would suggest on your side is that |
@marcelgerber just a quick look, isn't it possible to fix |
Well, the thing is, the leading slash is an indicator whether the path is absolute or relative, so we cannot decide that with the slash removed. |
I think Tern will only pass normalized file names to |
Yes, but the issue is that when an absolute path is normalized, the trailing slash is stripped so it looks like a relative one. |
I understand, but I think you can make your |
@zaggino Could you try adapting the |
Ok, I'm gonna look at this tomorrow and report back. |
(That's what I was talking about here ) |
@marcelgerber I though about something like this https://github.com/adobe/brackets/compare/zaggino/tern @marijnh I'd be useful if |
Just noticed my branch made 1 test failing on windows and it worked for like only half of the linux tests. This |
It's configured as no-op here: https://github.com/ternjs/tern/blob/459b6705bada72027fbb922f4097b4dcf0ab305d/lib/tern.js#L24 Why our
makes any difference? |
https://github.com/ternjs/tern/blob/0bf87473bc8c21f8d37e2ff6157edf9df8bde521/lib/tern.js#L222-L226 is the one we care about. The one you found is only the one that feeds this one :) @zaggino Your solution probably fails in cases like |
Ok, understood, your solution has my LGTM then. 👍 |
If @marijnh could provide an API for us to use would be great. |
I stated before that normalization is necessary for Tern to function reliably. If you break it like this, you'll get situations where the same file is referred to by different names (for example when found through a relative import), and the module system will get confused. I recommended to handle this in |
I'm afraid that for tern resolving to work properly as intended, we'd have to not use file system root as tern server root but actual require root (not project root, explanation follows). That brings us to a problem where project root might not be an actual requirejs root (if I open a subdirectory of a project). I can even have multiple requirejs roots in my opened folder structure (every default extension has its own require root https://github.com/adobe/brackets/blob/master/src/utils/ExtensionLoader.js#L172-L173 but usually you open just the brackets project). The only way I would know how to solve this problem is if in the |
...continuing my previous babble ...I don't think this is easily solvable (resolving requirejs stuff). If you have a file with a non-relative imports like |
👍 |
Yeah, for now I trust our test suite. |
…x absolute paths
Fixes two issues:
Extensions/JavaScript Code Hinting
tests fail on Linux/Mac (reported by @ficristo in Update Tern & Acorn #11569 (comment))Ctrl+Space
(reported by @zaggino on Slack)I could only test this on Linux.
The corresponding Tern "culprit" commit is ternjs/tern@24044a4