Skip to content

Css file containing a parsing error break extension #9

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

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions html-css-class-completion/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ function activate(context) {
vscode.window.showInformationMessage('HTML CSS Class Completion: Fetching CSS rules from CSS files, please wait.');
// fetches the css files excluding the ones within node_modules folders that are within another node_modules folder
vscode.workspace.findFiles('**/*.css', 'node_modules/**/node_modules/**/*').then(function (uris) {
// will contain all the css files concatenated
var cssFilesConcatenated = "";
// extracts the text of the file and directly parse it.
// if an error occurs during the parse hide the error (it could be shown into an error log)
try {
fetchClasses(textDocument.getText(), classes);
} catch (err) { }
// goes through each css file found and open it
uris.forEach(function (uri, index) {
vscode.workspace.openTextDocument(uri).then(function (textDocument) {
// extracts the text of the file and concatenates it
cssFilesConcatenated += textDocument.getText();
if (uris.length == index + 1) {
// after finishing the process the css classes are fetched from this large string and added to the classes array
fetchClasses(cssFilesConcatenated, classes);
// Display message to user
vscode.window.showInformationMessage("HTML CSS Class Completion: Finished fetching CSS rules from CSS files.");
}
});
Expand Down Expand Up @@ -138,6 +138,12 @@ function activate(context) {
});
context.subscriptions.push(disposable);

var disposable = vscode.commands.registerCommand('extension.html-css-class-completion.refresh', () => {
fetchAllCssRulesInCssFiles();
});

context.subscriptions.push(disposable);

fetchAllCssRulesInCssFiles();
//fetchAllCssRulesInHtmlFiles();
}
Expand All @@ -146,4 +152,4 @@ exports.activate = activate;
// this method is called when your extension is deactivated
function deactivate() {
}
exports.deactivate = deactivate;
exports.deactivate = deactivate;