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

Fix bugs of inserting braces after hash #237

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Fix bugs of inserting braces after hash #237

wants to merge 2 commits into from

Conversation

hediyi
Copy link

@hediyi hediyi commented Jul 25, 2016

fixes atom/language-ruby#153
fixes atom/language-ruby#132

The function name isCursorOnInterpolatedString is not very accurate, can I change it to isInterpolationAllowed or isCursorOnInterpolated?

hediyi added 2 commits July 28, 2016 19:52
The problem lies in the fact that "scopes at cursor" is actually the
scopes of the character on the right, so to determine if the cursor is
on an interpolated string, the character on the other side of the cursor
should also be checked, with two exceptions: when the cursor is at the
beginning or end of a line.

This patch aims to be clean, but not perfect:

** In some rare situations, such as when typing `#` at the beginning or
end of a line within a multi-line interpolated string, it won't expand
to `#{}`. **
@hediyi
Copy link
Author

hediyi commented Jul 28, 2016

🤘 @50Wliu Do you have time to review this?

@winstliu
Copy link
Contributor

winstliu commented Aug 5, 2016

I just checked and Ruby supports multiline strings, so I'm not sure this will work for those cases. Maybe add a check to make sure there's no punctuation scope?

@hediyi
Copy link
Author

hediyi commented Aug 6, 2016

lastCursor = @editor.getLastCursor()
scopesArrayOfLastCursor = lastCursor.getScopeDescriptor().getScopesArray()

return false if lastCursor.isAtBeginningOfLine() and scopesArrayOfLastCursor[scopesArrayOfLastCursor.length - 1].match(/punctuation(?:\.\w+)+\.begin/)

You mean something like this?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adding # right before % literals becomes #{} Add # just before a string add {}
2 participants