Skip to content

Commit 4e47f09

Browse files
committed
1 parent e0c02e7 commit 4e47f09

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

prqlc/prqlc/src/codegen/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,14 @@ pub trait WriteSource: std::fmt::Debug {
3131
Some(r)
3232
}
3333

34+
/// Attempts to write the current item, expanding the maximum width where necessary.
3435
fn write_or_expand(&self, mut opt: WriteOpt) -> String {
3536
loop {
3637
if let Some(s) = self.write(opt.clone()) {
3738
return s;
3839
} else {
40+
// TODO: could we just set the max width rather than increasing
41+
// it in a loop?
3942
opt.max_width += opt.max_width / 2;
4043
opt.reset_line();
4144
}
@@ -113,6 +116,8 @@ impl WriteOpt {
113116
Some(())
114117
}
115118

119+
/// Sets [WriteOpt::rem_width] to (max_width - indent_width), returning
120+
/// `Some(())`, or `None` if there's not enough space.
116121
fn reset_line(&mut self) -> Option<()> {
117122
let ident = self.tab.len() as u16 * self.indent;
118123
self.rem_width = self.max_width.checked_sub(ident)?;

0 commit comments

Comments
 (0)