lifted-studios / AutoCopyright

Plugin for Sublime Text 2 to automate adding/updating the appropriate copyright text at the top of the file.
MIT License
13 stars 5 forks source link

When updating, only match text in comments #10

Closed lee-dohm closed 11 years ago

lee-dohm commented 11 years ago

Sublime Text will give the scope of a match. The scope is the set of syntax highlighting rules that match the selection. We can use this to determine if the text is a comment or not. We should only update the text in comments, not other scopes.

lee-dohm commented 11 years ago
  1. Take the region of the match.
  2. Select any point in the region.
  3. Use View.scope_name(point) to determine that the point is in a comment.
  4. Use View.extract_scope(point) to determine the extent of the comment area.
  5. If the comment area includes the entirety of the match, then it is appropriate to replace it.