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

Make js2-beginning-of-defun skip comments #606

Merged
merged 1 commit into from
Dec 5, 2024
Merged

Conversation

evorion
Copy link
Contributor

@evorion evorion commented Dec 3, 2024

Make js2-beginning-of-defun skip comments. Fixes mark-defun bug for js2-mode when invoked inside a comment.

Make js2-beginning-of-defun skip comments. Fixes mark-defun bug for js2-mode when invoked inside a comment.
@dgutov
Copy link
Collaborator

dgutov commented Dec 4, 2024

Hi!

This kind of makes sense, but could you post a code sample which triggers the problem?

@evorion
Copy link
Contributor Author

evorion commented Dec 4, 2024

This is the one that does it for me. Calling mark-defun anywhere in a comment selects almost everything.

odoo.define('quotation_translation.DocumentDropZone', [], function (require) {
    "use strict";

    publicWidget.registry.DocumentDropZoneWidget = publicWidget.Widget.extend({
        selector: '#file-upload-container',

        events: {
            'change .file-input': 'onFileInputChange',
            'dragover': 'onDragOver',
            'dragenter': 'onDragEnter',
            'dragleave': 'onDragLeave',
            'drop': 'onDrop',
        },
        init: function (parent, options) {
            this._super.apply(this, arguments);
            this.options = Object.assign({
                'csrf_token': odoo.csrf_token,
            }, options || {});
            this.notification = this.bindService("notification");
        },
        onSendMeQuotation: function(e) {
            // var formData = $('#quotation-form').serializeArray();
            // formData.push({ name: 'sale_order.id', value: $('#quotation-form').data('sale_order.id') });

            // $.ajax({
            //     url: '/translatqon_quotation/confirm_send_quotation',
            //     context: this,
            //     type: 'POST',
            //     // headers: { 'Accept-Language': document.documentElement.lang },
            //     data: formData,
            //     success: (response) => {
            //         if (response['result'] == 'sent') {
            //             if (response['redirect'])
            //                 window.location.href = response['redirect'];
            //         }
            //     }
            // });
            var data = $('#quotation-form').serializeArray();

            return rpc('/translation_quotation/confirm_send_quotation',
                { data: data }
            ).then((response) => {
                if (response.result === 'sent')
                    if (response.redirect) window.location.href = response.redirect;
            }).catch((error) => { console.error('Error during quotation confirmation:', error); });
        },
        onDeleteSaleOrderLine: function(e) {
            return rpc('/translation_quotation/delete_sale_order_line', {
                sale_order_line_id: $(e.target).closest('tr').data('sale_order_line.id'),
            }).then(() => {
                $(e.target).closest('tr').prev().remove();
                $(e.target).closest('tr').remove();
                if ($('.sale-order-line').length === 1) $('#quotation-form').hide();
                this.notification.add('Sale order line deleted successfully!');
            });
        }
    });
});

@dgutov dgutov changed the title Update js2-mode.el Make js2-beginning-of-defun skip comments Dec 5, 2024
@dgutov
Copy link
Collaborator

dgutov commented Dec 5, 2024

Thanks! Merging.

For posterity: this change is needed because comment nodes are attached directly as children to the ast root node, not to any node enclosing it lexically.

@dgutov dgutov merged commit e0c3028 into mooz:master Dec 5, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants