# Undo not working when painting with terrain brush

**URL:** <https://discourse.mapeditor.org/t/undo-not-working-when-painting-with-terrain-brush/4140>\
**Category:** Bugs\
**Created:** [October 9, 2019, 5:39pm UTC](https://discourse.mapeditor.org/t/undo-not-working-when-painting-with-terrain-brush/4140 "2019-10-09T17:39:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ron1987](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.mapeditor.org/ron1987/32/1650_2.png) [@Ron1987](https://discourse.mapeditor.org/u/Ron1987)\
**Post date:** [October 9, 2019, 5:39pm UTC](https://discourse.mapeditor.org/t/undo-not-working-when-painting-with-terrain-brush/4140/1 "2019-10-09T17:39:43Z")

</div>

If I have a terrain bush and I paint on an empty layer, it work 100% fine, but I am unable to undo the changes. If I paint with a terrain brush over existing tiles, undo work fine.

To reproduce, create an empty map, then paint with the terrain brush over empty tiles. The tiles are painted, but undo doesn’t work.

---

<div class="post-metadata">

**Author:** ![bjorn](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.mapeditor.org/bjorn/32/1599_2.png) [@bjorn](https://discourse.mapeditor.org/u/bjorn)\
**Post date:** [October 9, 2019, 7:49pm UTC](https://discourse.mapeditor.org/t/undo-not-working-when-painting-with-terrain-brush/4140/2 "2019-10-09T19:49:32Z")

</div>

Please remember to also mention the version of Tiled you’re reporting the problem against. I found that this works fine in Tiled 1.2.4 but is broken in the latest snapshot.

It seems that it broke in [this recent change](https://github.com/bjorn/tiled/commit/6ca522e1e7b96802a9484d7a467ced2918a0d577), but it’s not immediately obvious to me why. I’ll dig into it soon. Thanks for the report!

---

<div class="post-metadata">

**Author:** ![bjorn](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.mapeditor.org/bjorn/32/1599_2.png) [@bjorn](https://discourse.mapeditor.org/u/bjorn)\
**Post date:** [October 17, 2019, 3:13pm UTC](https://discourse.mapeditor.org/t/undo-not-working-when-painting-with-terrain-brush/4140/3 "2019-10-17T15:13:19Z")

</div>

The following change takes care of this problem, hopefully without introducing new ones elsewhere:

> <https://github.com/bjorn/tiled/commit/5135b3f3dc1400f3d524a84da21b0408f9508472>

---

<div class="post-metadata">

**Author:** ![Ron1987](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.mapeditor.org/ron1987/32/1650_2.png) [@Ron1987](https://discourse.mapeditor.org/u/Ron1987)\
**Post date:** [October 17, 2019, 5:33pm UTC](https://discourse.mapeditor.org/t/undo-not-working-when-painting-with-terrain-brush/4140/4 "2019-10-17T17:33:27Z")

</div>

Thanks for the fix!
