File tree Expand file tree Collapse file tree 2 files changed +29
-9
lines changed
Expand file tree Collapse file tree 2 files changed +29
-9
lines changed Original file line number Diff line number Diff line change 382382 "type" : " boolean" ,
383383 "default" : true ,
384384 "description" : " Warn when the file of a texture property can't be found"
385+ },
386+ "sourceEngine.detectKeyvalueFiles.enabled" : {
387+ "type" : " boolean" ,
388+ "default" : true ,
389+ "description" : " Automatically use keyvalue file format for common file names like gameinfo.txt, subtitles_english.txt..."
390+ },
391+ "sourceEngine.detectKeyvalueFiles.customRules" : {
392+ "type" : " array" ,
393+ "default" : [],
394+ "description" : " Define custom rules to detect keyvalue files based on the file name"
395+ },
396+ "sourceEngine.detectKeyvalueFiles.onlyUseCustomRules" : {
397+ "type" : " boolean" ,
398+ "default" : false ,
399+ "description" : " Disables all the common file name rules that come with the extension. Useful if some standard rule is causing problems and you would rather define them yourself"
385400 }
386401 }
387402 },
Original file line number Diff line number Diff line change @@ -47,19 +47,24 @@ function onChangeEditor(document: vscode.TextDocument): void {
4747
4848function detectKeyvalueFile ( document : vscode . TextDocument ) : void {
4949
50+ const enabled = main . config . get ( "detectKeyvalueFiles.enabled" ) ;
51+ if ( ! enabled ) {
52+ return ;
53+ }
54+
5055 main . debugOutput . appendLine ( "File has language id: " + document . languageId ) ;
51- if ( document . languageId === "plaintext" ) {
52- main . debugOutput . appendLine ( `Potential kv file opened (${ document . uri . fsPath } )` ) ;
56+ if ( document . languageId !== "plaintext" ) return ;
5357
54- const langId = getPotentialKvFileLanguageId ( document ) ;
55- if ( langId === undefined ) {
56- main . debugOutput . appendLine ( `Not changing document language of (${ document . uri . fsPath } )` ) ;
57- return ;
58- }
58+ main . debugOutput . appendLine ( `Potential kv file opened (${ document . uri . fsPath } )` ) ;
5959
60- main . debugOutput . appendLine ( `Changing document language of (${ document . uri . fsPath } ) to keyvalue` ) ;
61- vscode . languages . setTextDocumentLanguage ( document , langId ) ;
60+ const langId = getPotentialKvFileLanguageId ( document ) ;
61+ if ( langId === undefined ) {
62+ main . debugOutput . appendLine ( `Not changing document language of (${ document . uri . fsPath } )` ) ;
63+ return ;
6264 }
65+
66+ main . debugOutput . appendLine ( `Changing document language of (${ document . uri . fsPath } ) to keyvalue` ) ;
67+ vscode . languages . setTextDocumentLanguage ( document , langId ) ;
6368}
6469
6570function getPotentialKvFileLanguageId ( document : vscode . TextDocument ) : DetectableLanguageId | undefined {
You can’t perform that action at this time.
0 commit comments