1. ZyX_I
  2. aurum

Commits

ZyX_I  committed 0a9599e

Fix writing file when exiting record mode from left buffer

If one runs record mode, edits some modified file and then uses discardall
mapping then edited file gets overwritten with version from repository

  • Participants
  • Parent commits 7b8b6a0
  • Branches default

Comments (0)

Files changed (3)

File autoload/aurum/record.vim

View file
  • Ignore whitespace
         execute swnr.'wincmd w'
         return s:F.runstatmap('commit')
     elseif a:action is# 'discardall'
+        " First discard. Otherwise when wiping out left buffer it may trigger 
+        " writing contents to the file.
+        call s:F.runleftmap('discard')
         execute swnr.'wincmd w'
         return s:F.runstatmap('discard')
     elseif a:action is# 'remove'

File test/cmd-record.in

View file
  • Ignore whitespace
 :Run 0
 :bwipeout!
 :
+:W{{{1 edit-discardall
+:R let g:oldhglines=readfile('hglines.lst', 'b')
+:R call writefile(['abcdef'], 'hglines.lst', 'b')
+:R AuRecord
+0:let g:fname=getline('.')[3:]
+:R let g:lines=readfile(g:fname, 'b')
+O,X
+:
+:
+:R let g:new_lines=readfile(g:fname, 'b')
+:R call WriteFile(glob('*.orig'))
+:if g:lines !=# g:new_lines | call WriteFile(['Lines differ for file '.g:fname.' (TEST FAILURE):', '{{{ old'] + g:lines + ['}}}', '{{{ new'] + g:new_lines + ['}}}']) | else | call WriteFile(['Lines do not differ for '.g:fname.' (expected)', '{{{'] + g:lines + ['}}}']) | endif
+:R call writefile(g:oldhglines, 'hglines.lst', 'b')
 :source addmessages.vim

File test/cmd-record.ok

View file
  • Ignore whitespace
 ^? 3
 After second remove: 3
 -? 3
+{{{1 edit-discardall
+Lines do not differ for hglines.lst (expected)
+{{{
+abcdef
+}}}
 >>> Messages: