Skip to content

Commit f13ca8d

Browse files
devvaannshabose
authored andcommitted
fix: instead of hard-coding file names use language manager
1 parent eb9fcd9 commit f13ca8d

File tree

1 file changed

+17
-6
lines changed
  • src/extensionsIntegrated/CustomSnippets

1 file changed

+17
-6
lines changed

src/extensionsIntegrated/CustomSnippets/helper.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
define(function (require, exports, module) {
2222
const StringMatch = require("utils/StringMatch");
23+
const LanguageManager = require("language/LanguageManager");
2324
const Global = require("./global");
2425
const UIHelper = require("./UIHelper");
2526
const Strings = require("strings");
@@ -823,16 +824,26 @@ define(function (require, exports, module) {
823824
return "all";
824825
}
825826

826-
const ext = fileExtension.toLowerCase();
827-
if (ext.includes(".js") || ext.includes(".ts")) {
828-
return "js";
827+
// get the first extension for categorization
828+
const firstExt = fileExtension.split(",")[0].trim();
829+
830+
let language = LanguageManager.getLanguageForExtension(firstExt);
831+
if (!language) {
832+
return "other";
829833
}
830-
if (ext.includes("html") || ext.includes("htm")) {
831-
return "html";
834+
835+
let langId = language.getId();
836+
837+
if(["javascript", "typescript", "jsx", "tsx"].includes(langId)) {
838+
return "js";
832839
}
833-
if (ext.includes("css") || ext.includes("less") || ext.includes("scss") || ext.includes("sass")) {
840+
if(["css", "scss", "less", "stylus"].includes(langId)) {
834841
return "css";
835842
}
843+
if(["html", "ejs", "erb_html"].includes(langId)) {
844+
return "html";
845+
}
846+
836847
return "other";
837848
}
838849

0 commit comments

Comments
 (0)