Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixing transpose expressions #202

Merged
merged 2 commits into from
Aug 17, 2020
Merged

fixing transpose expressions #202

merged 2 commits into from
Aug 17, 2020

Conversation

daviehh
Copy link
Contributor

@daviehh daviehh commented Jun 14, 2020

Potential fix for #200. Added condition such that transposing expressions foo', foo_' or [1 2 3]' does not autocomplete the '.

The bracket around v == '\'' && occursin(r"\w|\]", string(left_peek)) is more for readability, not really needed due to operator precedence, feel free to change/remove.

# left_peek == v: we already have an open quote immediately before (triple quote)
# regex is for transposing calls: issue #200
# regex: immediately after letter/_: \w or closing array bracket \]
left_peek == v || (v == '\'' && occursin(r"\w|\]", string(left_peek)))
Copy link
Owner

Choose a reason for hiding this comment

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

Is it possible to not use a regex here? It feels quite "heavy handed".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if the condition may be restricted to ' only auto-completes when the proceeding character is a blank space then no regex is needed. In that case, typing f=' will not auto-complete but [anything]Space' will auto-complete. This is sort-of-ok since good programming practice is to have spaces in expressions like foo = 'c'. If it's fine, then this line may be changed to

left_peek == v || (v == '\'' && left_peek != ' ')

Copy link
Owner

Choose a reason for hiding this comment

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

In that case, typing f=' will not auto-complete

It seems like you would want that to auto-complete.

Why is a regex needed otherwise? Can't it just be written out?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the feedback! I pushed a new commit to change to

isletter(left_peek) || isnumeric(left_peek) || left_peek == '_' || left_peek == ']'

to cover foo', foo3', foo_' and [1 2 3]'

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

Successfully merging this pull request may close these issues.

2 participants