Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[css mode] add caseInsensitive hint #6855

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions addon/hint/css-hint.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
return {list: ["!important"], from: CodeMirror.Pos(cur.line, token.start),
to: CodeMirror.Pos(cur.line, token.end)};

var start = token.start, end = cur.ch, word = token.string.slice(0, end - start);
var start = token.start, end = cur.ch, word = token.string.slice(0, end - start).toLowerCase();
if (/[^\w$_-]/.test(word)) {
word = ""; start = end = cur.ch;
}
Expand All @@ -41,7 +41,7 @@
function add(keywords) {
for (var name in keywords)
if (!word || name.lastIndexOf(word, 0) == 0)
result.push(name);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This definitely won't work for pseudoClasses defined above. What is it intended to do?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CSS is not case-sensitive. The current solution doesn't work with properties and values that the user will camelCase (ex. optimizeSpeed instead of optimizespeed). I want to fix this. Do you have any idea how to solve the problem with pseudoClasses?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No I mean, given that keySet is only called with lower-case strings, what is the purpose of making the object values hold another copy of the string?

result.push(keywords[name]);
}

var st = inner.state.state;
Expand Down
2 changes: 1 addition & 1 deletion mode/css/css.js
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
function keySet(array) {
var keys = {};
for (var i = 0; i < array.length; ++i) {
keys[array[i].toLowerCase()] = true;
keys[array[i].toLowerCase()] = array[i];
}
return keys;
}
Expand Down
8 changes: 7 additions & 1 deletion mode/css/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,5 +213,11 @@
"[def @font-face] [comment /* foo */] {",
" [property src]: [variable&callee url]([string x]);",
" [property font-family]: [variable One];",
"}")
"}");

MT("property-with-uPpeRCaSe",
"[tag p] { [property cOlOr]:[keyword red]; }");

MT("keyword-with-uPpeRCaSe",
"[tag p] { [property color]:[keyword oRanGe]; }");
})();