diff --git a/.gitignore b/.gitignore
index c53ca1a30c8db87557ca036e930e34c01a4e30fa..2004252cd1dc0278de933192001e1aaddcd679c8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,6 @@
 dwm/dwm
 dwm/drm
+dwm/.vscode
 dwm/drw.o
 dwm/dwm.o
 dwm/util.o
diff --git a/dwm/dwm.c b/dwm/dwm.c
index 85e71d9153e37e295144c47011ccec9c4918e6a2..855d80ce10b51cbf4aa7764b43130b3a71942817 100644
--- a/dwm/dwm.c
+++ b/dwm/dwm.c
@@ -1934,11 +1934,13 @@ tile(Monitor *m)
 		if (i < m->nmaster) {
 			h = (m->wh - my) / (MIN(n, m->nmaster) - i) - m->gappx;
 			resize(c, m->wx + m->gappx, m->wy + my, mw - (2*c->bw) - m->gappx, h - (2*c->bw), 0);
-			my += HEIGHT(c) + m->gappx;
+			if (my + HEIGHT(c) + m->gappx < m->wh)
+				my += HEIGHT(c) + m->gappx;
 		} else {
 			h = (m->wh - ty) / (n - i) - m->gappx;
 			resize(c, m->wx + mw + m->gappx, m->wy + ty, m->ww - mw - (2*c->bw) - 2*m->gappx, h - (2*c->bw), 0);
-			ty += HEIGHT(c) + m->gappx;
+			if (ty + HEIGHT(c) + m->gappx < m->wh)
+				ty += HEIGHT(c) + m->gappx;
 		}
 }