Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Add ruby string interpolation #70

Merged
merged 2 commits into from
Sep 22, 2014

Conversation

deiga
Copy link
Contributor

@deiga deiga commented Sep 18, 2014

Addresses #3

@@ -45,6 +45,9 @@ class BracketMatcher
return true if options?.select or options?.undo is 'skip'
return false if @isOpeningBracket(text) and @wrapSelectionInBrackets(text)
return true if @editor.hasMultipleCursors()
if text is '#' and _.find(@editor.getCursorScopes(), (scope) -> scope.indexOf("interpolated.ruby") != -1 or scope.indexOf("unquoted.heredoc.ruby") != -1 )?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You probably want to use a scope selector for this:

{ScopeSelector} = require 'first-mate'
interpolatedRubySelector = new ScopeSelect('interpolated.ruby')
if interpolatedRubySelector.matches(@editor.getCursorScopes())
  # it is interpolated ruby

You can see examples here:

@tagSelector = new ScopeSelector('meta.tag | punctuation.definition.tag')
@commentSelector = new ScopeSelector('comment.*')
patternForTagName: (tagName) ->
tagName = _.escapeRegExp(tagName)
new RegExp("(<#{tagName}([\\s>]|$))|(</#{tagName}>)", 'gi')
isRangeCommented: (range) ->
scopes = @editor.scopesForBufferPosition(range.start)
@commentSelector.matches(scopes)
isTagRange: (range) ->
scopes = @editor.scopesForBufferPosition(range.start)
@tagSelector.matches(scopes)
isCursorOnTag: ->
@tagSelector.matches(@editor.getCursorScopes())

@deiga
Copy link
Contributor Author

deiga commented Sep 20, 2014

@kevinsawicki I rewrote it to use a ScopeSelector, but I personally think that's way too verbose

@kevinsawicki
Copy link
Contributor

Great, thanks for this 👍

kevinsawicki added a commit that referenced this pull request Sep 22, 2014
@kevinsawicki kevinsawicki merged commit 4d0caee into atom:master Sep 22, 2014
@kevinsawicki
Copy link
Contributor

This will be included in the next Atom release, 0.130

@ghost

This comment has been minimized.

@deiga deiga deleted the add-ruby-string-interpolation branch May 14, 2020 13:20
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants