From f1dddea97b84e15d7bb945122c86f4e9c3da5fb7 Mon Sep 17 00:00:00 2001 From: WindR Date: Sat, 30 May 2026 12:07:01 +0300 Subject: [PATCH 1/2] Support files without extensions (e.g. hosts, Makefile, Dockerfile) The script only detects files by extension (e.g. `.js`, `.py`). Files without extensions like `hosts`, `Makefile`, `Dockerfile` are not recognized and the user is prompted to type an extension manually. Also fixed malformed `tpl` entry --- toggleComments.js | 119 ++++++++++++++++++++++++++++------------------ 1 file changed, 74 insertions(+), 45 deletions(-) diff --git a/toggleComments.js b/toggleComments.js index 5879d78..1357b8a 100644 --- a/toggleComments.js +++ b/toggleComments.js @@ -1,9 +1,9 @@ -// https://akelpad.sourceforge.net/forum/viewtopic.php?p=9924#p9924 +// https://akelpad.sourceforge.net/forum/viewtopic.php?p=9924#p9924 // https://infocatcher.ucoz.net/js/akelpad_scripts/toggleComments.js // https://github.com/Infocatcher/AkelPad_scripts/blob/master/toggleComments.js // (c) Infocatcher 2008-2022 -// Version: 0.4.4.1 - 2022-10-01 +// Version: 0.4.4.2 - 2026-05-30 // Author: Infocatcher //=================== @@ -63,53 +63,71 @@ var commentsSets = { // otherExtension: "extension" // Use "null" (without commas) for unavailable comments type. // First string will be used for comments adding (blockCommentStart0 and blockCommentEnd0 in example). - c: [ ["/*"], ["*/"], ["//"] ], - cpp: "c", - h: "c", - js: "c", - jsm: "c", - java: "c", "..php..": [ ["/*"], ["*/"], ["//", "#"] ], // Reserved - php: "..php..", // In case of -searchRegions=true we use html comments in *.php files and check - dpr: [ ["{", "(*"], ["}", "*)"], ["//"] ], - //pas: [ ["{", "(*"], ["}", "*)"], null ], - pas: "dpr", - html: [ [""], null ], - xhtml: "html", - shtml: "html", - htm: "html", - xml: "html", - xsl: "html", - xul: "html", - xbl: "html", - rdf: "html", - dtd: "html", - css: [ ["/*"], ["*/"], null ], - less: [ ["/*"], ["*/"], ["//"] ], + "1c": "1s", + "1s": [ null, null, ["//"] ], + //ahk: [ ["\r/*"], ["\r*/"], [";"] ], + ahk: [ null, null, [";"] ], asm: [ null, null, [";"] ], - ini: [ null, null, [";", "#"] ], + au3: [ ["#comments-start", "#cs"], ["#comments-end", "#ce"], [";"] ], + aucfg: [ null, null, ["#"] ], + awk: [ null, null, ["#"] ], + bas: [ null, null, ["'", '"'] ], bat: [ null, null, ["::", "rem "] ], + c: [ null, null, ["//"] ], + cfg: "aucfg", cmd: "bat", - vbs: [ null, null, ["'", "rem "] ], + coder: [ null, null, [";"] ], + cpp: "c", + css: [ ["/*"], ["*/"], null ], + dockerfile: "sh", + dpr: [ ["{", "(*"], ["}", "*)"], ["//"] ], + dtd: "html", + gitconfig: "ini", + gitignore: "sh", + h: "c", + hhp: "ini", + highlight: [ null, null, [";"] ], + hosts: "sh", + htaccess: [ null, null, ["#"] ], + htm: "html", + html: [ [""], null ], + ini: [ null, null, [";", "#"] ], + iss: "c", + java: "c", + js: "c", + jsm: "c", + less: [ ["/*"], ["*/"], ["//"] ], lss: [ ["%REM"], ["%END REM"], ["'"] ], + lst: "py", + lua: [ ["--[["], ["]]"], ["--"] ], + makefile: "sh", manifest: [ null, null, ["#"] ], + mnu: "ini", //AkelPad menu file + nsi: [ null, null, [";", "#"] ], + //pas: [ ["{", "(*"], ["}", "*)"], null ], + pas: "dpr", + pb: "ahk", + php: "..php..", // In case of -searchRegions=true we use html comments in *.php files and check + php: [ [""], null ], properties: [ null, null, ["#"] ], - highlight: [ null, null, [";"] ], - coder: [ null, null, [";"] ], - sql: [ ["/*"], ["*/"], ["--"] ], - htaccess: [ null, null, ["#"] ], - //ahk: [ ["\r/*"], ["\r*/"], [";"] ], - ahk: [ null, null, [";"] ], - awk: [ null, null, ["#"] ], - sh: [ null, null, ["#"] ], + ps1: [ ["<#"], ["#>"], ["#"] ], py: [ null, null, ["#"] ], pyw: "py", - "1s": [ null, null, ["//"] ], - "1c": "1s", - nsi: [ null, null, [";", "#"] ], - au3: [ ["#comments-start", "#cs"], ["#comments-end", "#ce"], [";"] ], - lua: [ ["--[["], ["]]"], ["--"] ], - ps1: [ ["<#"], ["#>"], ["#"] ] + rdf: "html", + reg: "ini", + sh: [ null, null, ["#"] ], + shtml: "html", + spck: [ null, null, [";"] ], + sql: [ ["/*"], ["*/"], ["--"] ], + tcg: [ null, null, [" ;; "] ], + tpl: [ ["{*"], ["*}"], ["//"] ], + vbs: [ null, null, ["'", "rem "] ], + xbl: "html", + xhtml: "html", + xml: "html", + xsl: "html", + xul: "html" }; var commentsRegions = { // Example: @@ -1199,11 +1217,22 @@ function restoreLineScroll(hWnd, nBeforeLine) function getCurrentExt() { var ext; var cFile = AkelPad.GetEditFile(0); - if(cFile && /\.([^.]+)$/i.test(cFile)) { - ext = RegExp.$1.toLowerCase(); // js, css, etc. - if(ext && !commentsSets[ext]) - ext = null; + if(cFile) { + // Strip the path, keep only the filename + var fileName = cFile.replace(/^.*[\\\/]/, "").toLowerCase(); + + // 1. Check if the full filename matches an entry (e.g. "hosts") + if(commentsSets[fileName]) { + ext = fileName; + } + // 2. Otherwise, fall back to extension detection + else if(/\.([^.]+)$/i.test(fileName)) { + ext = RegExp.$1.toLowerCase(); // js, css, etc. + if(ext && !commentsSets[ext]) + ext = null; + } } + if(!ext || !searchRegions && commentsRegions[ext]) { var coderExt = getCoderExt(); if(coderExt) @@ -1328,4 +1357,4 @@ function stringRepeat(pattern, count) { pattern += pattern; } return result + pattern; -} \ No newline at end of file +} From 61b1cedbca4dd3c597edbaf410b6841271ff8075 Mon Sep 17 00:00:00 2001 From: WindR Date: Sat, 30 May 2026 12:12:07 +0300 Subject: [PATCH 2/2] Update version --- toggleComments.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/toggleComments.js b/toggleComments.js index 1357b8a..9b23355 100644 --- a/toggleComments.js +++ b/toggleComments.js @@ -3,7 +3,7 @@ // https://github.com/Infocatcher/AkelPad_scripts/blob/master/toggleComments.js // (c) Infocatcher 2008-2022 -// Version: 0.4.4.2 - 2026-05-30 +// Version: 0.4.5.0 - 2026-05-30 // Author: Infocatcher //===================