@@ -13,7 +13,7 @@ var YAML = require('yamljs');
13
13
import * as jisonTest from './JisonTest' ;
14
14
var Parser = require ( "jison" ) . Parser ;
15
15
import JsonTmLanguageCompletionItemProvider from './JsonTmLanguageCompletionItemProvider' ;
16
- import jsonTmLanguageDiagnosticProvider from './jsonTmLanguageDiagnosticProvider'
16
+ import jsonTmLanguageDiagnosticProvider from './jsonTmLanguageDiagnosticProvider' ;
17
17
18
18
19
19
export const JSON_FILE : vscode . DocumentFilter = { language : 'json-tmlanguage' , scheme : 'file' } ;
@@ -95,6 +95,7 @@ class FileConverter{
95
95
96
96
try {
97
97
var extension : string ;
98
+ // should do lower case compare
98
99
switch ( destinationLanguage ) {
99
100
case "json-tmlanguage" :
100
101
extension = "JSON-tmLanguage" ;
@@ -110,28 +111,30 @@ class FileConverter{
110
111
}
111
112
var documentText = doc . getText ( ) ;
112
113
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
+
113
120
var sourceLanguage = doc . languageId ;
114
121
115
122
// check to see if file already exists
116
123
vscode . workspace . findFiles ( filename + "*." + extension , "ABC" ) . then ( matchingFiles => {
117
124
var paths = matchingFiles . map ( p => p . fsPath ) ;
118
125
119
126
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 ) {
123
128
var counter = 1 ;
124
129
while ( paths . indexOf ( path ) >= 0 ) {
125
130
path = join ( vscode . workspace . rootPath , './' + filename + '(' + counter + ').' + extension ) ;
126
131
counter ++ ;
127
132
}
128
-
129
- this . OpenTextDocument ( sourceLanguage , destinationLanguage , documentText , path ) ;
130
- }
133
+ }
134
+ this . OpenTextDocument ( sourceLanguage , destinationLanguage , documentText , path ) ;
131
135
} ) ;
132
136
} catch ( err ) {
133
137
console . log ( err ) ;
134
- var sdf = 3 ;
135
138
}
136
139
}
137
140
0 commit comments