Skip to content

Commit

Permalink
Finishing touches for reindenting functionality
Browse files Browse the repository at this point in the history
The `self.Indent()` call needs to be moved downwards, because otherwise
indenting is done before the filetype is set.
  • Loading branch information
AndrewRadev committed Nov 13, 2012
1 parent c7fde90 commit 7c7b867
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
9 changes: 3 additions & 6 deletions autoload/linediff/differ.vim
Expand Up @@ -82,23 +82,20 @@ function! linediff#differ#CreateDiffBuffer(edit_command) dict
exe a:edit_command . " " . temp_file exe a:edit_command . " " . temp_file
call append(0, lines) call append(0, lines)
$delete _ $delete _
call self.Indent()
set nomodified set nomodified
normal! gg normal! gg


let self.diff_buffer = bufnr('%') let self.diff_buffer = bufnr('%')
call self.SetupDiffBuffer() call self.SetupDiffBuffer()
call self.Indent()


diffthis diffthis
endfunction endfunction


" Indents the current buffer content so that format can be ignored. " Indents the current buffer content so that format can be ignored.
function! linediff#differ#Indent() dict function! linediff#differ#Indent() dict
if !exists("g:linediff_indent") if g:linediff_indent
let g:linediff_indent = 0 silent normal! gg=G
endif
if g:linediff_indent == 1
normal! gg=G
endif endif
endfunction endfunction


Expand Down
15 changes: 15 additions & 0 deletions doc/linediff.txt
Expand Up @@ -4,6 +4,7 @@ CONTENTS *linediff* *linediff-contents*
Installation...........................: |linediff-installation| Installation...........................: |linediff-installation|
Usage..................................: |linediff-usage| Usage..................................: |linediff-usage|
Commands...............................: |linediff-commands| Commands...............................: |linediff-commands|
Settings...............................: |linediff-settings|
Internals..............................: |linediff-internals| Internals..............................: |linediff-internals|
Issues.................................: |linediff-issues| Issues.................................: |linediff-issues|


Expand Down Expand Up @@ -92,6 +93,20 @@ COMMANDS *linediff-commands*
buffers are untouched by this, which means that any updates buffers are untouched by this, which means that any updates
to them, performed by the diff process will remain. 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* INTERNALS *linediff-internals*


Expand Down
6 changes: 5 additions & 1 deletion plugin/linediff.vim
@@ -1,11 +1,15 @@
if exists("g:loaded_linediff") || &cp if exists('g:loaded_linediff') || &cp
finish finish
endif endif


let g:loaded_linediff = '0.1.1' " version number let g:loaded_linediff = '0.1.1' " version number
let s:keepcpo = &cpo let s:keepcpo = &cpo
set cpo&vim 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 " Initialized lazily to avoid executing the autoload file before it's really
" needed. " needed.
function! s:Init() function! s:Init()
Expand Down

0 comments on commit 7c7b867

Please sign in to comment.