Fix flood fill infinite loop when color under cursor matches fill color

This commit is contained in:
Isaiah Odhner 2023-04-24 21:58:32 -04:00
parent a91dd25996
commit 61227597f8
2 changed files with 2 additions and 2 deletions

View File

@ -125,7 +125,6 @@ The rest match MS Paint's keyboard shortcuts:
- Some languages don't display correctly.
- Large files can make the program very slow.
- The program sometimes crashes or freezes randomly.
- The program freezes when using the fill tool on a spot already filled with the target color.
## Development

View File

@ -818,7 +818,8 @@ def flood_fill(document: AnsiArtDocument, x: int, y: int, fill_ch: str, fill_fg:
return (
document.ch[y][x] == original_ch and
document.bg[y][x] == original_bg and
(original_ch == " " or document.fg[y][x] == original_fg)
(original_ch == " " or document.fg[y][x] == original_fg) and
(document.ch[y][x] != fill_ch or document.bg[y][x] != fill_bg or document.fg[y][x] != fill_fg)
)
def set_cell(x: int, y: int) -> None: