Skip to content
This repository was archived by the owner on Oct 16, 2020. It is now read-only.

Fix preloading of files from code fixes on Windows #377

Merged
merged 3 commits into from
Oct 24, 2017
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/typescript-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1245,7 +1245,9 @@ export class TypeScriptService {

return this.projectManager.ensureOwnFiles(span)
.concat(Observable.defer(() => {
const configuration = this.projectManager.getConfiguration(fileTextChanges[0].fileName)
// Configuration lookup uses Windows paths, FileTextChanges uses unix paths. Convert to backslashes.
const firstChangedFile = uri2path(path2uri(fileTextChanges[0].fileName))
Copy link
Contributor

@felixfbecker felixfbecker Oct 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the purpose of this is to convert to backslashes, why not simply do filename.replace(/\//g, '\\')? Converting to a URI and back seems like a hack

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that the intention is to only do it if it's a path with a drive letter, I'd still prefer to leave the URI functions out of this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it's not the cleanest looking solution :) I'll extract the needed logic from uri2path.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

const configuration = this.projectManager.getConfiguration(firstChangedFile)
configuration.ensureBasicFiles(span)

const changes: {[uri: string]: TextEdit[]} = {}
Expand Down