Skip to content

Be smarter about comments #5

@jcartledge

Description

@jcartledge

If the selection does not start or end in a comment, matches in comments should be ignored. Otherwise look inside comments.

Sample code:

import sublime
import sublime_plugin

# This is a comment.
# Place the cursor in here and enter in the console:
# >>> view.run_command('test_comment')
# => source.python comment.line.number-sign.python
# Should be safe to check for /comment/ ?


class TestCommentCommand(sublime_plugin.TextCommand):
    """ This is a string not a comment
    """
    def run(self, edit):
        sel = self.view.sel()[0]
        scope = self.view.scope_name(sel.begin())
        sublime.message_dialog(scope)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions