Permalink
Browse files

Finishing touches for reindenting functionality

The `self.Indent()` call needs to be moved downwards, because otherwise
indenting is done before the filetype is set.
  • Loading branch information...
1 parent c7fde90 commit 7c7b867867700abfa2ea132348cf175f3a385c00 @AndrewRadev committed Nov 13, 2012
Showing with 23 additions and 7 deletions.
  1. +3 −6 autoload/linediff/differ.vim
  2. +15 −0 doc/linediff.txt
  3. +5 −1 plugin/linediff.vim
@@ -82,23 +82,20 @@ function! linediff#differ#CreateDiffBuffer(edit_command) dict
exe a:edit_command . " " . temp_file
call append(0, lines)
$delete _
- call self.Indent()
set nomodified
normal! gg
let self.diff_buffer = bufnr('%')
call self.SetupDiffBuffer()
+ call self.Indent()
diffthis
endfunction
" Indents the current buffer content so that format can be ignored.
function! linediff#differ#Indent() dict
- if !exists("g:linediff_indent")
- let g:linediff_indent = 0
- endif
- if g:linediff_indent == 1
- normal! gg=G
+ if g:linediff_indent
+ silent normal! gg=G
endif
endfunction
View
@@ -4,6 +4,7 @@ CONTENTS *linediff* *linediff-contents*
Installation...........................: |linediff-installation|
Usage..................................: |linediff-usage|
Commands...............................: |linediff-commands|
+ Settings...............................: |linediff-settings|
Internals..............................: |linediff-internals|
Issues.................................: |linediff-issues|
@@ -93,6 +94,20 @@ COMMANDS *linediff-commands*
to them, performed by the diff process will remain.
==============================================================================
+SETTINGS *linediff-settings*
+
+ *g:linediff_indent*
+>
+ let g:linediff_indent = 1
+<
+
+Default value: 0
+
+If this flag is set to 1, linediff will reindent the diffed sections in order
+to minimize differences caused by formatting. This may change the buffers'
+contents.
+
+==============================================================================
INTERNALS *linediff-internals*
When a block of text is diffed with the plugin, a "Differ" object is
View
@@ -1,11 +1,15 @@
-if exists("g:loaded_linediff") || &cp
+if exists('g:loaded_linediff') || &cp
finish
endif
let g:loaded_linediff = '0.1.1' " version number
let s:keepcpo = &cpo
set cpo&vim
+if !exists('g:linediff_indent')
+ let g:linediff_indent = 0
+endif
+
" Initialized lazily to avoid executing the autoload file before it's really
" needed.
function! s:Init()

0 comments on commit 7c7b867

Please sign in to comment.