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

Add assert!() and assert_eq!() snippets. #321

Merged
merged 1 commit into from
May 23, 2018
Merged

Add assert!() and assert_eq!() snippets. #321

merged 1 commit into from
May 23, 2018

Conversation

OnlyLys
Copy link
Contributor

@OnlyLys OnlyLys commented May 18, 2018

As I understand it, RLS relies on Racer for snippet autocompletion (rls/#827). But since snippet autocompletion for macros hasn't been implemented yet (rls/#829), I propose we add two more commonly used macros: assert!() and assert_eq!() to rls-vscode as a temporary measure.

Later on, when macro autocompletion is implemented we should be able to remove these without breaking anything.

"assert": {
"prefix": "assert",
"body": [
"assert!($1)$0"
Copy link
Member

Choose a reason for hiding this comment

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

The syntax here and for assert_eq looks wrong, should it be assert!($1, $0)? Also I don't see why it is in this order and not $0, $1.

Copy link
Contributor Author

@OnlyLys OnlyLys May 23, 2018

Choose a reason for hiding this comment

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

Hi @nrc, the $0 tabstop in a snippet actually denotes the final cursor position. Its purpose is to allow users to 'jump out' of the braces on the final 'tab' keypress. It's very convenient because it allows users to add a semicolon at the end without needing to manually move the cursor there.

But it's not only added there for convenience reasons, it's also to have parity with function snippet completions. If you're familiar with them, they all have a final tabstop immediately to the right of the closing brace.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the explanation!

@nrc nrc merged commit 6d2e40b into rust-lang:master May 23, 2018
Xanewok pushed a commit to Xanewok/rls-vscode that referenced this pull request Mar 27, 2019
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.

2 participants