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

Typing assist: implement typing assist on delete/backspace inside records #324

Open
wants to merge 4 commits into
base: net222
Choose a base branch
from

Conversation

seclerp
Copy link
Member

@seclerp seclerp commented Nov 14, 2021

This PR implements delete/backspace assist for cases when the caret is inside record declaration/instance to help in deletion of redundant whitespace. The feature also works for anonymous records and records with attributes as well.

Examples:

Definition:

type SomeRecord =
   { field1: string
     field2: string
     {caret}field3: string }

Backspace:

type SomeRecord =
   { field1: string
     field2: string; field3: string }

Instance:

// Before
let someRecord =
   { field1 = "Quick"
     field2 = "Brown"{caret}
     field3 = "Fox" }

Delete:

let someRecord =
   { field1 = "Quick"
     field2 = "Brown"; field3 = "Fox" }

@seclerp seclerp changed the base branch from net213 to net221 November 15, 2021 14:22
@auduchinok
Copy link
Member

auduchinok commented Nov 25, 2021

@seclerp Could you pleas add tests for cases where the typing assist shouldn't do the additional formatting, please?

An example for Delete, there's a space after the caret:

{ A = 1 {caret} 
  B = 1
  ...

Please also consider how this should work next to comments and empty lines.

@seclerp
Copy link
Member Author

seclerp commented Nov 26, 2021

@auduchinok thanks for that catch, I added missing tests and also improved typing assist. Now when backspace is pressed before record field with preceding empty line (or line with only whitespace symbols) indentation is kept:

let record = {
  field1 = "Hello"

  {caret}field2 = "World"
}

Backspace:

let record = {
  field1 = "Hello"
  {caret}field2 = "World"
}

@seclerp seclerp changed the base branch from net221 to net222 April 10, 2022 00:43
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.

None yet

2 participants