Skip to content

Commit da33d09

Browse files
authored
fix(ls): improve windows file escaping (#9)
Fixed #3
1 parent ac31d6b commit da33d09

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

client/src/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export function activate(context: ExtensionContext) {
1515
// Otherwise the run options are used
1616
let serverOptions: ServerOptions = {
1717
run : { module: serverModule, transport: TransportKind.ipc },
18-
debug: { module: serverModule, transport: TransportKind.ipc /*, options: debugOptions */ }
18+
debug: { module: serverModule, transport: TransportKind.ipc /* *, options: debugOptions /* */ }
1919
}
2020

2121
// Options to control the language client

server/src/documents.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ class ProjectLoggerImpl implements ProjectLogger {
101101
}
102102
}
103103

104+
declare function escape(text: string): string;
104105
declare function unescape(text: string): string;
105106

106107
function uriToFileName(uri: string): string {
@@ -118,7 +119,10 @@ function uriToFileName(uri: string): string {
118119

119120
const fileProtocol = "file://";
120121
export function fileNameToUri(fileName: string): string {
121-
return encodeURI(fileProtocol + fileName);
122+
if (fileName.match(/^\w:/)) {
123+
fileName = '/' + fileName;
124+
}
125+
return fileProtocol + escape(fileName);
122126
}
123127

124128
export interface NgServiceInfo {
@@ -257,6 +261,7 @@ export class TextDocuments {
257261
}
258262
return {fileName, languageId};
259263
}
264+
return {};
260265
}
261266

262267
public ifUnchanged(f: () => void): () => void {

0 commit comments

Comments
 (0)