Skip to content

Javascript function within a function loses syntax highlighting #10567

Closed

Description

@micmic0615
  • 1.4
  • windows 10:

Steps to Reproduce:

  1. after putting a function inside a function in javascript, everything below that line will no longer be highlighted.

vscode bug screenie

Activity

  1. alexdima commented on Aug 16, 2016

    @alexdima
    Member

    micmic0615 Can you please provide the text so we can copy-paste it.

  2. added
    info-needed
    on Aug 16, 2016
  3. micmic0615 commented on Aug 16, 2016

    @micmic0615
    Author

    the attached test.js file has no syntax errors but I'm losing the highlighting.

    loads of long JS files in my website are also like this (lose highlights midway) even though they are running.

    test.zip

  4. added
    bug
    and removed
    info-needed
    on Aug 16, 2016
  5. wallethub-labs commented on Aug 17, 2016

    @wallethub-labs

    micmic0615 you can revert to 1.3.1 until this is fix. We experienced this issue too, something about a bug in OCaml grammar

  6. alexdima commented on Aug 29, 2016

    @alexdima
    Member

    Here is the analysis. There is definitely some sort of grammar bug in there, but it doesn't look too bad. By the end of the file, there are 7 rules on the stack (instead of the expected 1):

    /*  4 */ mongoose.connection.on('open', function(ref) {
    /*  7 */     mongoose.connection.db.listCollections().toArray(function(err, collections) {
    /* 10 */        glob("*app/models/*.js", {}, function(er, files) {          
    /* 13 */            prm.cols.settings.findOne({ 'key': 'front-end_template' }, 'parameters', function (err, template) {     
    /* 16 */                glob("*app/routes/*.js", {}, function (er, files) {
    /* 16 */                    for (var i = 0; i < files.length; i++) { var filename = files[i].split('.js')[0].split('/routes/')[1]; declareRoute(filename) };
    /* 16 */                
    /* 16 */ 
    /* 17 */                    if (template_config.auto_page_routing == true) {
    /* 19 */                        function getPage(p, base) {
    /* 19 */                            var filename = base + p[p.length - 1].split('.')[0];
    /* 19 */ 
    /* 20 */                            if (filename == base + "index") { var route = "/" + base }
    /* 21 */                            else { var route = "/" + filename };
    /* 21 */ 
    /* 24 */                            app.get(route, prm.mdws.isLoggedIn, function (req, res) {
    /* 27 */                                prm.cols.job_levels.find({}, function (err, result) {
    /* 27 */                                    var page_path = template_path + template_config.auto_page_routing_folder + filename + '.ejs';
    /* 27 */ 
    /* 28 */                                    data = {
    /* 30 */                                        login: {
    /* 30 */                                            _id: req.user._id,
    /* 30 */                                            FirstName: req.user.local.FirstName,
    /* 30 */                                            FamilyName: req.user.local.FamilyName,
    /* 30 */                                            Email: req.user.local.CompanyEmail,
    /* 30 */                                            Permissions: req.user.local.Permissions,
    /* 30 */                                            Picture:req.user.local.Picture,
    /* 30 */                                            LocalNetwork: req.user.LocalNetwork,
    /* 31 */                                            Job:req.user.local.Job
    /* 28 */                                        },
    /* 28 */                                        job_levels: result,
    /* 29 */                                        page_path:page_path
    /* 27 */                                    };
    /* 27 */ 
    /* 27 */                                    res.render(page_path, page_functions(req, res, data));
    /* 24 */                                });
    /* 21 */                            });
    /* 20 */                        };
    /* 20 */                    } else {
    /* 20 */                        finalizeRoutes()
    /* 19 */                    }
    /* 19 */ 
    /* 20 */                    if (template_config.manual_page_routes.length > 0) {
    /* 21 */                        for (var i = 0; i < template_config.manual_page_routes.length; i++) {
    /* 21 */                            var p = template_config.manual_page_routes[i];
    /* 21 */                            declareCustomPage(p.route, p.file, p.settings)
    /* 20 */                        }
    /* 20 */ 
    /* 22 */                        function declareCustomPage(route, file, settings) {
    /* 23 */                            if (settings.no_login == true) {
    /* 26 */                                app.get(route, function (req, res) {
    /* 26 */                                    req.q_spd = q_spd; 
    /* 26 */                                    res.render(template_path + file, page_functions(req, res));
    /* 23 */                                })
    /* 23 */                            } else {
    /* 26 */                                app.get(route, prm.mdws.isLoggedIn, function (req, res) {
    /* 26 */                                    req.q_spd = q_spd(); 
    /* 26 */                                    
    /* 29 */                                    prm.cols.job_levels.find({}, function (err, result) {
    /* 29 */                                        var page_path = template_path + file;
    /* 29 */                                        data = settings;
    /* 29 */                                            
    /* 30 */                                        data.login = {
    /* 30 */                                            _id: req.user._id,
    /* 30 */                                            FirstName: req.user.local.FirstName,
    /* 30 */                                            FamilyName: req.user.local.FamilyName,
    /* 30 */                                            Email: req.user.local.CompanyEmail,
    /* 30 */                                            Permissions: req.user.local.Permissions,
    /* 30 */                                            Picture:req.user.local.Picture,
    /* 30 */                                            LocalNetwork: req.user.LocalNetwork,
    /* 31 */                                            Job:req.user.local.Job
    /* 29 */                                        };
    /* 29 */ 
    /* 29 */                                        data.job_levels = result,
    /* 29 */                                        data.page_path = page_path
    /* 29 */                                        
    /* 29 */                                        
    /* 29 */                                        res.render(page_path, page_functions(req, res, data));
    /* 26 */                                    });
    /* 23 */                                });
    /* 22 */                            }
    /* 20 */                        }
    /* 20 */ 
    /* 20 */                        finalizeRoutes();
    /* 20 */                    } else {
    /* 20 */                        finalizeRoutes();
    /* 19 */                    }
    /* 19 */ 
    /* 21 */                    function finalizeRoutes() {
    /* 21 */                        routes_done++;
    /* 22 */                        if (routes_done >= 2) {
    /* 22 */                            for (var i = 0; i < app._router.stack.length; i++) { if (app._router.stack[i].name == "serveStatic") { app._router.stack.splice(i, 1) } }
    /* 22 */                            app.use(express.static('./app/views/' + template_path + template_config.public_folder));
    /* 22 */                            app.all('*', prm.mdws.isLoggedIn);
    /* 22 */                            app.all('*', prm.mdws.createQueryLog);
    /* 22 */ 
    /* 25 */                            app.use(function (req, res, next) {
    /* 25 */                                var fileCheck = fileExists(template_path + '_he-404.ejs');
    /* 26 */                                if (fileCheck) {
    /* 26 */                                    res.status(404).render(template_path + '_he-404.ejs', page_functions(req, res));
    /* 26 */                                } else {
    /* 26 */                                    res.status(404).render('default/files/_he-404.ejs', page_functions(req, res));
    /* 25 */                                }
    /* 22 */                            });
    /* 21 */                        };
    /* 19 */                    };
    /* 19 */                    
    /* 19 */                    require('./config/cron.js')(prm);
    /* 19 */                    
    /* 19 */                    var http = require("http").Server(app);
    /* 19 */                    http.listen(config.env.port);
    /* 19 */ 
    /* 19 */                    prm.io = require('socket.io')(http);
    /* 19 */                    
    /* 22 */                    glob("*app/controllers/sockets/*.js", {}, function (er, files) {
    /* 22 */                        var socketActions = [];
    /* 23 */                        for (var i = 0; i < files.length; i++) {
    /* 23 */                            var filename = files[i].split('.js')[0].split('/sockets/')[1];
    /* 23 */                            socketActions.push(filename)
    /* 22 */                        };
    /* 22 */ 
    /* 25 */                        prm.io.on('connection', function (socket) {
    /* 26 */                            for (var i = 0; i < socketActions.length; i++) {
    /* 26 */                                var p = socketActions[i];
    /* 26 */                                require('./app/controllers/sockets/' + p + '.js')(prm, socket, p);
    /* 25 */                            }
    /* 25 */ 
    /* 28 */                            socket.on('disconnect', function () {
    /* 28 */ 
    /* 25 */                            });
    /* 22 */                        });
    /* 19 */                    });
    /* 19 */                    
    /* 19 */                    module.exports = app;
    /* 19 */                    var log_date = new Date();
    /* 19 */                    var log_months = ["Jan", "Feb", "Mar", "Apr", "May", "June", "July", "Aug", "Sept", "Oct", "Nov", "Dec"];
    /* 19 */                    console.log(log_months[log_date.getMonth()] + ' ' + log_date.getDate() + ', ' + log_date.getFullYear() +  " - " + log_date.getHours() + ":" + log_date.getMinutes() + ":" + log_date.getSeconds() +  " ---  server running at http://" + config.env.domain + ':' + config.env.port);
    /* 17 */                }); 
    /* 16 */            }); 
    /* 13 */        });
    /* 10 */     });
    /* 7 */ })
  7. alexdima commented on Aug 29, 2016

    @alexdima
    Member

    I've extracted the grammar bug to microsoft/TypeScript-TmLanguage#252

    We should also bump the protection limit from 30 to some larger value. Let's track that in #9937

  8. micmic0615 commented on Aug 30, 2016

    @micmic0615
    Author

    i don't really understand your fix logs. But since you closed it, I'm assuming a fix has been applied?

    will just wait for the next update, if so. thanks!

  9. alexdima commented on Aug 30, 2016

    @alexdima
    Member

    micmic0615 The fix will come in the stable build with the August release, or you can get the fix now using the Insiders channel https://code.visualstudio.com/insiders

  10. micmic0615 commented on Aug 30, 2016

    @micmic0615
    Author

    tnx!

  11. added
    verified
    on Aug 31, 2016
  12. locked and limited conversation to collaborators on Nov 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugverified

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions