refmt: sometimes new lines are unnecessary in switch cases
Nobody has claimed this yet.
- Dominant language
- OCaml
- Stars
- 10.3k
- Forks
- 438
- PR merge metrics
- No merged PRs in 30d
Description
I'm just starting with Reason and I'm using Reason Language Server with coc.nvim. I'm playing with the formatting feature using a simple function from Reason docs, though I'm not finding it pretty for this function in particular:
let isVowel = (theChar) =>
switch (theChar) {
| 'a' | 'e' | 'i' | 'o' | 'u' | 'y' => true
| _ => false
};
Formatting that results in:
let isVowel = theChar =>
switch (theChar) {
| 'a'
| 'e'
| 'i'
| 'o'
| 'u'
| 'y' => true
| _ => false
};
I really didn't wish the vowels options to split in individual lines for this case. I was basically expecting to just fix the whitespace in let isVowel = (theChar). So I tried range formatting just in that part but the server doesn't format it alone, it requires the whole function for formatting it.
I'm not sure though how this can be tackled since splitting switch cases in multiple lines may be useful in most occasions.
Issue migrated from https://github.com/jaredly/reason-language-server/issues/211.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with refmt and reproduce the Reason example from the issue, comparing the current output with the requested formatting. Trace the switch-case formatting behavior and determine a rule that avoids unnecessary line breaks without removing useful multiline formatting; done means the example formats as expected and existing switch-case behavior remains intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ocaml
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100