Skip to content

Commit

Permalink
Fix smart-indent to expand tabs to the next tab point rather than doi…
Browse files Browse the repository at this point in the history
…ng a simple replace.
  • Loading branch information
fragglet committed Jun 1, 2008
1 parent 563b9c0 commit 0a8ff8e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tools/smart-indent
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0a8ff8e

Please sign in to comment.