Lossless end of line comment wrapping.
Nobody has claimed this yet.
- Dominant language
- OCaml
- Stars
- 10.3k
- Forks
- 438
- PR merge metrics
- No merged PRs in 30d
Description
One problem with eol comments is that we can not easily reformat or wrap items because we loose the fact that the eol (end of line) comment applied to the item whose beginning token is the first non-white space character.
We cannot allow the thing an eol comment applies to wrap without regard for the eol comment. For example, imagine that the following eol comment:
let x = myFunction a c /* eol comment on let */
Were to wrap as follows:
let x =
myFunction
a
c /* eol comment on let */
It would appear the eol comment is on the c now.
So we must attach end of line comments in a way that allow the content to break and eol comments to break with it, never loosing track of which item the eol comment was attached to. We may be able to accomplish this by having eol comments break as after line comments. We can then consider after-line comments as being simply another "view" on eol comments. There would only be two total forms of comments, before and eol comments, but eol comments would have two "renderings" which are both lossless. The other benefits are that eol comments may be rendered "out of your way" (and the end of the line) when you have the available screen real estate and rendered underneith an item when space is tight.
let x =
myFunction
a
c
/*on x eol-mode that happened to wrap */
let nextBinding = ...
Note there must be an empty line after the eol comment when rendered in 'after-line' mode, and there may be a space before it. The required space after the broken comment line is to ensure that it is not confused with a "before line" comment in a following binding.
The only other question would be if eol comments rendered in this second mode should be somehow indented so as to make unambiguous room for a third form of comments: true after line comments. Personally, I think could end up looking confusing.
I will try to move forward with whatever approach is technically feasible.
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
No files, tests, or entry points are named. First locate the existing end-of-line comment wrapping implementation and its tests, then determine how comment attachment is represented; done should preserve the original attachment while supporting the proposed ordinary and after-line renderings.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ocaml
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 18/100