diff --git a/lib/codemirror.js b/lib/codemirror.js
index b0e38c2196295ba85f17f0c5aaede2d346d6543b..390e68c1fbe1edfbd30241ce6f263578bcd10031 100644
--- a/lib/codemirror.js
+++ b/lib/codemirror.js
@@ -143,8 +143,9 @@ var CodeMirror = (function() {
       lineInfo: lineInfo,
       addWidget: function(pos, node, scroll) {
         var pos = localCoords(clipPos(pos), true);
-        node.style.top = pos.yBot + "px"; node.style.left = pos.x + "px";
-        lineSpace.appendChild(node);
+        node.style.top = (showingFrom * lineHeight() + pos.yBot + paddingTop()) + "px";
+        node.style.left = (pos.x + paddingLeft()) + "px";
+        code.appendChild(node);
         if (scroll)
           scrollIntoView(pos.x, pos.yBot, pos.x + node.offsetWidth, pos.yBot + node.offsetHeight);
       },