vscode-cssvar
vscode-cssvar copied to clipboard
[Bug] Find ways to fix duplication in local css source files
VSCode has started to push CSS Variables into the auto-complete list, when the variables are defined in the same file that a user is working on.
This causes unnecessary duplicates as mentioned here: https://github.com/willofindie/vscode-cssvar/issues/66#issue-1360803627
This bug is opened to find if there's any possible way to fix this issue. I feel there's one way to fix this: do not populate the auto-complete list (with variables from a source file which is what the user is currently working on as well. (This applies to only CSS and similar files)
Just a thought, need to test this, and figure out if this is functional and fixes the issue or not.
It would be ok, if it removes the duplicates from folders above.
I think it is not so easy to detect which one has precedence in the same folder, cause it does not know which file is included first.
Yeah, precedence of variables is a challenge. We can keep a context of where the variables were created, but I still feel it wouldn't solve our problem, cause variables can be defined anywhere, and could also be nested.
if it removes the duplicates from folders above.
I couldn't understand this statement. Which folders are you talking about?
I couldn't understand this statement. Which
foldersare you talking about?
Example
index.css ; with variable --var1: red
|- somedir
|- some.css ; with variable --var1: blue
If you work in some.css and use --var it shows --var1 twice, one with red, one with blue
But this is not wrong, cause CSSVar did not know if some.css is included before index.css.
"Static Solution" with an option eliminate-precedence: it should eleminate --var1 from the file above (if we not work in that folder, depending on current file).
A better non static solution: integrate a callback (include a js method from e.g. .vscode/cssvar.cjs), so that we can set our own custom sort order and priority for included files.
This function needs as parameters a list of all vars und associated filenames and the current working file.
It should return a list with vars & values, that could be used in the current file.