]> git.cworth.org Git - sup/blobdiff - lib/sup/modes/scroll-mode.rb
bugfix: clear cached lambda hook locals after hook call
[sup] / lib / sup / modes / scroll-mode.rb
index 66c098be06b43d343ac7b0e120589d71b3ea20f7..63b48ec00edd6e7b7cc50bd82b51d8b00c7c7ed9 100644 (file)
@@ -73,7 +73,7 @@ class ScrollMode < Mode
     end
     if line
       @search_line = line + 1
-      search_goto_pos line, col, col + @search_query.length
+      search_goto_pos line, col, col + @search_query.display_length
       buffer.mark_dirty
     else
       BufferManager.flash "Not found!"
@@ -164,7 +164,7 @@ protected
           if match
             return [i, offset + match]
           else
-            offset += string.length
+            offset += string.display_length
           end
         end
       end
@@ -219,24 +219,25 @@ protected
 
   def draw_line_from_array ln, a, opts
     xpos = 0
-    a.each do |color, text|
+    a.each_with_index do |(color, text), i|
       raise "nil text for color '#{color}'" if text.nil? # good for debugging
+      l = text.display_length
+      no_fill = i != a.size - 1
       
-      if xpos + text.length < @leftcol
+      if xpos + l < @leftcol
         buffer.write ln - @topline, 0, "", :color => color,
                      :highlight => opts[:highlight]
-        xpos += text.length
       elsif xpos < @leftcol
         ## partial
         buffer.write ln - @topline, 0, text[(@leftcol - xpos) .. -1],
                      :color => color,
-                     :highlight => opts[:highlight]
-        xpos += text.length
+                     :highlight => opts[:highlight], :no_fill => no_fill
       else
         buffer.write ln - @topline, xpos - @leftcol, text,
-                     :color => color, :highlight => opts[:highlight]
-        xpos += text.length
+                     :color => color, :highlight => opts[:highlight],
+                     :no_fill => no_fill
       end
+      xpos += l
     end
   end