Open reefhound opened 1 year ago
Found the issue. In Extensions.js (In Kami's version, Yuteng's is obfuscated) is this function:
function isIncludedFile(fileName) { return config.filesToIncludes.find((globPattern) => globToRegexp(globPattern).test(fileName)) !== undefined; }
Replacing the return to just check for hardcoded extension makes files of that extension work. function isIncludedFile(fileName) { return fileName.endsWith(".qss"); )
So there is something whacked with the regex and my regex skills are weak.
Nope. Same fail.
Besides, the forked version has essentially the same code as the original in the function isIncludedFile. line 164 of Extensions.js of fork return config.filesToIncludes.find((globPattern: string) => globToRegexp(globPattern).test(fileName)) !== undefined;
line 149 of Extensions.js of original return config.filesToIncludes.find((globPattern) => globToRegexp(globPattern).test(fileName)) !== undefined;
@reefhound try latest version
@reefhound try latest version
Did you actually try the latest version? You can add a non-Language Supported file pattern in "colorize.include" and get it to activate and colorize?
I have the latest code in the repo. The canColorize function is what determines if the page is activated. It does not even look at "colorize.exclude". In fact, there is a comment that it needs to be added and the include needs to be reworked. And the isIncludedFile function is the same as what I posted in post #2 so it hasn't been changed.
/**
colorize.include
setting/**
isLanguageSupported
? checking path with file extension or include glob pattern should be enough
return isLanguageSupported(document.languageId) || isIncludedFile(document.fileName);
}@reefhound I mean try my latest version. I publish a new version instead of official version. The official version is not maintained any more. I fixed it in this commit: https://github.com/tjx666/vscode-colorize/commit/1f913876944ff1e49fbc002d4559b4106ca916e5
I'm not installing "open source" that has been obfuscated. Where is the development repo? I'll be able to tell if it's fixed from looking at the code itself.
I've already fixed Kami's for myself. Since all I care about is absolute extensions, I only check the extension. I get the extension and do a simple check that the filename ends with the extension. I added an exclude function and allowed an exclude match to short circuit the canColorize function.
/**
colorize.exclude
settingcolorize.include
settingnever mind, found your code. Looks like you replaced find with some and added the exclude check inline rather than separate function, I'll test.
I installed your latest and still not working for me. My settings: "colorize.include": ["/*.qss"], "colorize.exclude": ["*/.css", "/*.scss"], "colorize.colorized_colors": ["BROWSERS_COLORS", "HEXA", "RGB", "HSL"], "colorize.languages": ["css", "sass", "scss", "less", "xml", "svg"]
My snippet to colorize: QLineEdit { background-color:#D8BFD8; border:2px solid #6272a4; color:#586796; }
This snippet, in a filename with an included qss extension, does not activate and colorize yet in an excluded css extension continues to active and colorize.
Note that your exclusion check comes after your language check so an excluded file that is language supported will never get excluded. In my fix, I do the exclusion check first.
function isIncludedFile(fileName: string): boolean { if (config.filesToExcludes.some((globPattern) => globToRegexp(globPattern).test(fileName))) { return false; } return config.filesToIncludes.some((globPattern: string) => globToRegexp(globPattern).test(fileName), ); }
/**
isLanguageSupported
? checking path with file extension or include glob pattern should be enough
return isLanguageSupported(document.languageId) || isIncludedFile(document.fileName);
}you need write **/*.qss
, not /*.qss
"colorize.include": ["/*.qss"], "colorize.exclude": ["*/.css", "/*.scss"],
I have it as double asterisk, slash, asterisk extension. It's this discussion board software changing it.
I will fix the exclude logic tomorrow, I need to sleep now.
The qss file can be colorized in my local machine, I will show you my settings and screenshot tomorrow
{
"colorize.languages": ["css", "scss", "less", "xml", "svg"],
"colorize.enable_search_variables": false,
"colorize.include": [
"**/*.css",
"**/*.scss",
"**/*.sass",
"**/*.less",
"**/*.styl",
"**/*.qss"
],
}
I had publish a new version fix the exclude logic https://github.com/tjx666/vscode-colorize/commit/6aa0231c1c6369645bccb9a07fe9f55a3cad66d8
Just tried latest, still doesn't work for me. I did a complete uninstall, restart, install cycle. I think something else is going on. The code in the commit looks ok. Are you sure the build pipeline is working right? Have you confirmed it working on your end with the production version? I'm just wondering if the package reg-to-exp is the problem.
I'm using the latest version of Vscode on Windows 10. The extension version shows as 0.12.8
I think you're not using Windows. Could be the way Windows uses backslashes instead of forward slashes in filenames. Not sure if glob-to-regexp supports Windows.
There's a later version forked. kd-glob-to-regexp 0.4.2
Looking at index.js of the dependency glob-to-regexp, it appears to be a single function that parses the input string one character at a time and builds the regex string. In the switch cases I don't see a check for "\" which is how the Windows path separator would look.
can you provide a screenshot of this extension homepage in vscode. I want to ensure you are using my latest version
can you provide a screenshot of this extension homepage in vscode? I want to ensure you are using my latest version
Pretty sure it's the latest. I can see the newest functions in the extension code, though obfuscated and minified.
function fr(r){return f.filesToExcludes.some(e=>(0,he.default)(e).test(r))}function hr(r){return f.filesToIncludes.some(e=>(0,he.default)(e).test(r))}
I'm outside visiting my relatives.I will test it on windows tonight
You need write **\\*.qss
on windows:
@reefhound try latest version
Works now. Great job.
The Colorize tray icon says "Colorize is not activated for this file"
I'm trying to colorize qss files, Python's PyQt styling. I have my settings as: "colorize.include": [ "*/.qss" ],
The content is similar to CSS and colorizes fine when pasted into a file with a .css extension so the issue is it's not processing the .qss file. I have not seen one person report getting this to work. Is there some additional step required?
I've tried both the original version by Kami and the newer fork.
Also, the "colorize.exclude" doesn't work either. I added to exclude .css and it still colorizes it even after restart. "colorize.exclude": ["*/.css", "*/.scss"],