<commit_before>function! writable_search#proxy#New(parent_buffer)
  return {
        \ 'parent_buffer': a:parent_buffer,
        \ 'filename':      '',
        \ 'lines':         [],
        \ 'start_line':    -1,
        \ 'end_line':      -1,
        \
        \ 'Render':       function('writable_search#proxy#Render'),
        \ 'UpdateSource': function('writable_search#proxy#UpdateSource'),
        \ 'UpdateLocal':  function('writable_search#proxy#UpdateLocal'),
        \ 'RenameFile':   function('writable_search#proxy#RenameFile'),
        \ }
endfunction

function! writable_search#proxy#Render() dict
  let header = self.filename . ':' . self.start_line . '-' . self.end_line

  call append(line('$'), header)
  for line in self.lines
    " additional space used for editability
    call append(line('$'), ' '.line)
  endfor
endfunction

" Updates the source file with the new lines given. Adjusts its start and end
" points by the given a:adjustment. Returns the difference in lines in order
" to adjust next proxies.
function! writable_search#proxy#UpdateSource(new_lines, adjustment) dict
  let new_lines = a:new_lines

  " don't do anything if there was no change
  if new_lines == self.lines
    return 0
  endif

  " Adjust given lines
  let self.start_line += a:adjustment
  let self.end_line   += a:adjustment

  " Switch to the source buffer, delete the relevant lines, add the new
  " ones, switch back to the diff buffer.
  let saved_bufhidden = &bufhidden
  let &bufhidden = 'hide'

  exe 'silent edit ' . fnameescape(self.filename)
  setlocal nofoldenable

  call cursor(self.start_line, 1)
  if self.end_line - self.start_line >= 0
    silent exe self.start_line . ',' . self.end_line . 'delete _'
  endif
  call append(self.start_line - 1, new_lines)
  silent write
  exe 'silent buffer ' . self.parent_buffer
<commit_msg>Match case when comparing new lines to changed lines<commit_after>function! writable_search#proxy#New(parent_buffer)
  return {
        \ 'parent_buffer': a:parent_buffer,
        \ 'filename':      '',
        \ 'lines':         [],
        \ 'start_line':    -1,
        \ 'end_line':      -1,
        \
        \ 'Render':       function('writable_search#proxy#Render'),
        \ 'UpdateSource': function('writable_search#proxy#UpdateSource'),
        \ 'UpdateLocal':  function('writable_search#proxy#UpdateLocal'),
        \ 'RenameFile':   function('writable_search#proxy#RenameFile'),
        \ }
endfunction

function! writable_search#proxy#Render() dict
  let header = self.filename . ':' . self.start_line . '-' . self.end_line

  call append(line('$'), header)
  for line in self.lines
    " additional space used for editability
    call append(line('$'), ' '.line)
  endfor
endfunction

" Updates the source file with the new lines given. Adjusts its start and end
" points by the given a:adjustment. Returns the difference in lines in order
" to adjust next proxies.
function! writable_search#proxy#UpdateSource(new_lines, adjustment) dict
  let new_lines = a:new_lines

  " don't do anything if there was no change
  if new_lines ==# self.lines
    return 0
  endif

  " Adjust given lines
  let self.start_line += a:adjustment
  let self.end_line   += a:adjustment

  " Switch to the source buffer, delete the relevant lines, add the new
  " ones, switch back to the diff buffer.
  let saved_bufhidden = &bufhidden
  let &bufhidden = 'hide'

  exe 'silent edit ' . fnameescape(self.filename)
  setlocal nofoldenable

  call cursor(self.start_line, 1)
  if self.end_line - self.start_line >= 0
    silent exe self.start_line . ',' . self.end_line . 'delete _'
  endif
  call append(self.start_line - 1, new_lines)
  silent write
  exe 'silent buffer ' . self.parent_buffer

{'fraction_non_alphanumeric': 0.10888175494917068, 'fraction_numerical': 0.0032102728731942215, 'mean_word_length': 3.1590656284760845, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1765852', 'n_tokens_mistral': 1176, 'n_tokens_neox': 1145, 'n_words': 326}