Skip to content

Commit

Permalink
Snippets should have the correct line delimiters when inserted
Browse files Browse the repository at this point in the history
  • Loading branch information
danlucraft committed Mar 14, 2010
1 parent 5cdfdf9 commit 7d63ffb
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion plugins/snippets/lib/snippets/document_controller.rb
Expand Up @@ -104,7 +104,7 @@ def insert_snippet(snippet)
@stop_id = 0

@env = Textmate::Environment.new

fix_line_endings
# Not sure what to do about backticks. Currently they don't work in Redcar.
#@content = execute_backticks(@content, bundle ? bundle.dir : nil)
selection_range = document.selection_range
Expand All @@ -130,6 +130,12 @@ def leading_whitespace(line)
line[/^(\s*)([^\s]|$)/, 1].chomp
end

def fix_line_endings
if document.delim != "\n" # textmate uses "\n" everywhere
@content = @content.gsub("\n", document.delim)
end
end

def compute_tab_stop(line, tab_width, soft_tabs)
re = / {0,#{tab_width - 1}}\t|#{" "*tab_width}/
sc = StringScanner.new(leading_whitespace(line))
Expand Down

0 comments on commit 7d63ffb

Please sign in to comment.