mirror of
https://github.com/1j01/textual-paint.git
synced 2024-09-11 15:56:03 +03:00
Fix shifted/cutoff selection when melding with negative coordinates
Code intended to prevent errors was also creating an offset between the source and target regions. The source region needs to be adjusted to match the clipped target region.
This commit is contained in:
parent
0c52788843
commit
1f171259bb
@ -138,7 +138,6 @@ cat file.ans
|
||||
- Large files can make the program very slow, as can magnifying the canvas.
|
||||
- The program sometimes crashes or freezes randomly, and there's no auto-save feature.
|
||||
- Saved ANSI files are unnecessarily large, because they include escape sequences for every cell, even if the colors match the previous cell.
|
||||
- When finalizing a selection that is partially outside the document bounds to the top or to the left, it gets cut off.
|
||||
|
||||
The program has only been tested on Linux. Issues on other platforms are as-yet _unknown_ :)
|
||||
|
||||
|
7
paint.py
7
paint.py
@ -467,8 +467,13 @@ class Selection:
|
||||
if not self.contained_image:
|
||||
# raise ValueError("Selection has no image data.")
|
||||
return
|
||||
|
||||
# Prevent out of bounds errors (IndexError: list assignment index out of range)
|
||||
# by clipping the target region to the document, and adjusting the source region accordingly.
|
||||
target_region = self.region.intersection(Region(0, 0, document.width, document.height))
|
||||
document.copy_region(source=self.contained_image, target_region=target_region, mask=self.mask)
|
||||
source_region = Region(target_region.x - self.region.x, target_region.y - self.region.y, self.contained_image.width, self.contained_image.height)
|
||||
|
||||
document.copy_region(source=self.contained_image, source_region=source_region, target_region=target_region, mask=self.mask)
|
||||
|
||||
|
||||
debug_region_updates = False
|
||||
|
Loading…
Reference in New Issue
Block a user