From 0a8ff8e0e83de9ab42efd352c5204f030f945a17 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sun, 1 Jun 2008 19:27:48 +0000 Subject: [PATCH] Fix smart-indent to expand tabs to the next tab point rather than doing a simple replace. --- tools/smart-indent | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/smart-indent b/tools/smart-indent index 3e6079b..ca99537 100755 --- a/tools/smart-indent +++ b/tools/smart-indent @@ -29,7 +29,12 @@ def fix_file(filename) # expand tabs - s = s.gsub(/\t/, " " * TAB_SIZE) + while s =~ /\t/ + lead_text = $` + lead_len = lead_text.length + replace_len = TAB_SIZE - (lead_len % TAB_SIZE) + s[0, lead_len + 1] = lead_text + " " * replace_len + end # replace leading spaces with the appropriate combination # of tabs and spaces