-
-
Notifications
You must be signed in to change notification settings - Fork 329
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
More multiline, and some comment support #7695
More multiline, and some comment support #7695
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, looking good. I don't have any significant comments.
}; | ||
if (comment) |c| { | ||
token.offset = c.begin; | ||
token.extra = .{ .length = if (c.end > c.begin) c.end - c.begin else 0 }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would end ever be less than begin?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point
@@ -435,9 +449,15 @@ pub const Cursor = struct { | |||
} | |||
} else if (b == '#') { | |||
self.pos += 1; | |||
const comment_start = self.pos; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rather make this part of the return value (eg in a struct) than stuff this in a field on self
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking of removing the u16 for the indent completely - since it's no longer used (or needed).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense to me!
if (self.cursor.chompTrivia()) |indent| { | ||
self.output.pushNewline(indent); | ||
if (self.cursor.chompTrivia()) |_| { | ||
self.output.pushNewline(self.cursor.popComment()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to clarify this, newlines instead of store the indent now store the index to any comments that appear between lines?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They store the start and endposition
src/fmt.zig
Outdated
fmt.push(braces.end()); | ||
} | ||
|
||
fn formatExpr(fmt: *Formatter, ei: ExprIdx) IR.Region { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed the returned region is almost always ignored. What is it actually needed/used for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's used by formatCollection to flush comments and newlines (normalized) between the items
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See fmt.zig:212 above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me. I think there are some merge conflicts that need to be resolved first tho.
9e505de
to
f1328a6
Compare
This is ready to merge!