]> git.mdlowis.com Git - projs/tide.git/commitdiff
copyindent now literally copies the indent characters from the previous line. This...
authorMichael D. Lowis <mike.lowis@gentex.com>
Tue, 20 Dec 2016 21:06:09 +0000 (16:06 -0500)
committerMichael D. Lowis <mike.lowis@gentex.com>
Tue, 20 Dec 2016 21:06:09 +0000 (16:06 -0500)
TODO.md
libedit/buf.c

diff --git a/TODO.md b/TODO.md
index 4edf7505b7ce011d06a838283baf97dac200ec65..59c26a7fb74a1d33f946933f78d3c4c0a2d73aa1 100644 (file)
--- a/TODO.md
+++ b/TODO.md
@@ -1,5 +1,6 @@
 # Implementation Tweaks and Bug Fixes
 
+* Indent on first line of buffer causes infinite loop
 * block selection should handle brace-balancing
 * Add tag for ctags lookup and line number jump
 * add a shortcut to autocomplete ctag
@@ -11,6 +12,7 @@
 
 Nice to haves: 
 
+* focus should follow mouse between regions
 * Expand tabs setting should be disabled if opened file contains tabs
 * Add a tools dir to namespace utility scripts only useful inside the editor
 * shift+click to extend selection
index 573769997dbc62982f6da5d99daf3f9404abb213..59e06f1ef0f4e065cd1672daaa52edbaabb5fbdb 100644 (file)
@@ -109,12 +109,6 @@ static void clear_redo(Buf* buf) {
     buf->redo = NULL;
 }
 
-static unsigned getindent(Buf* buf, unsigned off) {
-    off = buf_bol(buf, off);
-    for (; off < buf_end(buf) && (' ' == buf_get(buf, off) || '\t' == buf_get(buf, off)); off++);
-    return buf_getcol(buf, off) / TabWidth;
-}
-
 static void delete(Buf* buf, unsigned off) {
     syncgap(buf, off);
     buf->gapend++;
@@ -287,9 +281,10 @@ unsigned buf_insert(Buf* buf, bool fmt, unsigned off, Rune rune) {
         }
     }
     if (fmt && buf->copy_indent && (rune == '\n' || rune == RUNE_CRLF)) {
-        unsigned indent = getindent(buf, off-1);
-        for (; indent > 0; indent--)
-            off = buf_insert(buf, indent, off, '\t');
+        unsigned beg = buf_bol(buf, off-1), end = beg;
+        for (; end < buf_end(buf) && (' ' == buf_get(buf, end) || '\t' == buf_get(buf, end)); end++);
+        for (; beg < end; beg++)
+            off = buf_insert(buf, true, off, buf_get(buf, beg));
     }
     clear_redo(buf);
     return off;