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

Remove empty line in required-properties snippet insertion #3721

Merged
merged 5 commits into from
Jul 26, 2021

Conversation

bhsubra
Copy link
Contributor

@bhsubra bhsubra commented Jul 22, 2021

Fixes #3632

@@ -493,7 +493,6 @@ public async Task VerifyResourceBodyCompletionWithDiscriminatedObjectTypeContain
azCliVersion: $3
retentionInterval: $4
}
Copy link
Member

Choose a reason for hiding this comment

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

}

Since the $0 is removed, where does the cursor land after the snippet is committed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question. Right now it places it outside the top level close curly brace. Placing it at column 0 at ln 9 in the below screenshot might be simple. I am not sure if we want ln 8. That might be tricky. Let me know what you think.

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, final tab stop was always before the last '}'. So added it back without the newline as part of:
ee8fa54

Let me know if you have any questions/concerns.

Copy link
Member

Choose a reason for hiding this comment

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

I think the answer depends on what the most likely action is after tab stopping through the snippet. If most of the time, the user doesn't add more properties, then we could actually put $0 after the last curly.

If we we think the user will most often add another property, then we might have to put $0 at the end of the value of the last property we inserted because pressing enter would let them add the property easily.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense. Should we wait for more customer feedback regarding placement of final tab stop($0)? @MarcusFelling, @alex-frankel do you have any inputs?

Copy link
Member

Choose a reason for hiding this comment

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

I thought about it some more. My guess is the following:

  • Adding more top-level properties to resources is rare, so it's probably ok to assume that the user isn't going to do it.
  • There are only 1-2 top-level writable properties in modules (name and params), so users will not be adding more.
  • Many swaggers don't mark all the inner (not top-level) properties as required, so I'm guessing users are more likely to add properties inside the resource.
  • I don't know how likely the users are to provide values for optional module params.

Thoughts? This could get pretty complex, so I'm definitely open to keeping the logic simple. Just wanted to discuss first.

Copy link
Member

@anthony-c-martin anthony-c-martin Jul 26, 2021

Choose a reason for hiding this comment

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

I think the answer depends on what the most likely action is after tab stopping through the snippet. If most of the time, the user doesn't add more properties, then we could actually put $0 after the last curly.

I agree with this solution - it feels impossible to really predict what the user's next action is going to be, so putting a $0 after the last curly feels like the most agnostic option.

Inserting a $0 into the 'top-level' object (the current behavior) feels like we're attempting to make a prediction that inserting another top-level property is important - but who's to say the user cares about adding top-level properties, or perhaps the property they actually want to insert isn't actually a top-level property. IMO it feels best to offer a consistent experience that doesn't make significant predictions that are potentially incorrect.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Had an offline discussion with @anthony-c-martin. Does anyone object to having the final tab stop to be outside the resource after last } at ln9 in above screenshot?

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good to me.

Copy link
Member

@majastrz majastrz left a comment

Choose a reason for hiding this comment

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

:shipit:

@bhsubra bhsubra force-pushed the dev/bhsubra/FixForIssue3632 branch from 2f7985a to cb14e64 Compare July 26, 2021 21:21
@bhsubra bhsubra merged commit ebfd1fa into main Jul 26, 2021
@bhsubra bhsubra deleted the dev/bhsubra/FixForIssue3632 branch July 26, 2021 22:03
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.

required-properties snippet on a module inserts an additional blank line
3 participants