Skip to content
This repository was archived by the owner on Sep 3, 2021. It is now read-only.

Commit 6786309

Browse files
committedMay 10, 2016
Ignore comment line at the beginning of files
1 parent eb1d5aa commit 6786309

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed
 

‎src/extension.ts

+11-8
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ var YAML = require('yamljs');
1313
import * as jisonTest from './JisonTest';
1414
var Parser = require("jison").Parser;
1515
import JsonTmLanguageCompletionItemProvider from './JsonTmLanguageCompletionItemProvider';
16-
import jsonTmLanguageDiagnosticProvider from './jsonTmLanguageDiagnosticProvider'
16+
import jsonTmLanguageDiagnosticProvider from './jsonTmLanguageDiagnosticProvider';
1717

1818

1919
export const JSON_FILE: vscode.DocumentFilter = { language: 'json-tmlanguage', scheme: 'file' };
@@ -95,6 +95,7 @@ class FileConverter{
9595

9696
try{
9797
var extension: string;
98+
// should do lower case compare
9899
switch (destinationLanguage) {
99100
case "json-tmlanguage":
100101
extension = "JSON-tmLanguage";
@@ -110,28 +111,30 @@ class FileConverter{
110111
}
111112
var documentText = doc.getText();
112113

114+
// Some of the sublime tmlanguage variant files had comments as hints for auto conversion
115+
if (documentText.startsWith("//")){
116+
var lastLineRange = doc.lineAt(doc.lineCount - 1).range;
117+
documentText = doc.getText(new vscode.Range(new vscode.Position(1, 0), lastLineRange.end));
118+
}
119+
113120
var sourceLanguage = doc.languageId;
114121

115122
// check to see if file already exists
116123
vscode.workspace.findFiles(filename + "*." + extension, "ABC").then(matchingFiles => {
117124
var paths = matchingFiles.map(p => p.fsPath);
118125

119126
var path = join(vscode.workspace.rootPath, './' + filename + '.' + extension);
120-
if (matchingFiles.length == 0){
121-
this.OpenTextDocument(sourceLanguage, destinationLanguage, documentText, path);
122-
} else {
127+
if (matchingFiles.length != 0){
123128
var counter = 1;
124129
while (paths.indexOf(path) >= 0){
125130
path = join(vscode.workspace.rootPath, './' + filename + '(' + counter +').' + extension);
126131
counter++;
127132
}
128-
129-
this.OpenTextDocument(sourceLanguage, destinationLanguage, documentText, path);
130-
}
133+
}
134+
this.OpenTextDocument(sourceLanguage, destinationLanguage, documentText, path);
131135
});
132136
} catch(err) {
133137
console.log(err);
134-
var sdf = 3;
135138
}
136139
}
137140

0 commit comments

Comments
 (0)
This repository has been archived.