Ensure correct coordinate ordering in selection file write

When writing selected text to file, use `topLeft` and `bottomRight` instead of
`start` and `end` to ensure correct coordinate ordering. This fixes an issue
where selection files could be empty when selecting text in reverse order.

- Use `terminal.Selection.topLeft()` for start coordinate
- Use `terminal.Selection.bottomRight()` for end coordinate
This commit is contained in:
Bryan Lee
2024-12-30 22:55:01 +08:00
committed by Jonathan Lopez
parent 2584468276
commit 995bc54639

View File

@ -4293,11 +4293,16 @@ fn writeScreenFile(
tmp_dir.deinit();
return;
};
// Use topLeft and bottomRight to ensure correct coordinate ordering
const tl = sel.topLeft(&self.io.terminal.screen);
const br = sel.bottomRight(&self.io.terminal.screen);
try self.io.terminal.screen.dumpString(
buf_writer.writer(),
.{
.tl = sel.start(),
.br = sel.end(),
.tl = tl,
.br = br,
.unwrap = true,
},
);