Skip to content

Be smarter about comments #5

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)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions