Remove the redundant fix_buffer_data vars and filename variables
This commit is contained in:
parent
81a8c77d20
commit
846bfb47b2
4 changed files with 1 additions and 22 deletions
|
@ -192,12 +192,7 @@ endfunction
|
||||||
" Every variable name will be prefixed with 'ale_'.
|
" Every variable name will be prefixed with 'ale_'.
|
||||||
function! ale#Var(buffer, variable_name) abort
|
function! ale#Var(buffer, variable_name) abort
|
||||||
let l:full_name = 'ale_' . a:variable_name
|
let l:full_name = 'ale_' . a:variable_name
|
||||||
let l:vars = getbufvar(str2nr(a:buffer), '', 0)
|
let l:vars = getbufvar(str2nr(a:buffer), '', {})
|
||||||
|
|
||||||
if l:vars is 0
|
|
||||||
" Look for variables from deleted buffers, saved from :ALEFix
|
|
||||||
let l:vars = get(get(g:ale_fix_buffer_data, a:buffer, {}), 'vars', {})
|
|
||||||
endif
|
|
||||||
|
|
||||||
return get(l:vars, l:full_name, g:[l:full_name])
|
return get(l:vars, l:full_name, g:[l:full_name])
|
||||||
endfunction
|
endfunction
|
||||||
|
|
|
@ -420,9 +420,7 @@ function! ale#fix#InitBufferData(buffer, fixing_flag) abort
|
||||||
" The 'done' flag tells the function for applying changes when fixing
|
" The 'done' flag tells the function for applying changes when fixing
|
||||||
" is complete.
|
" is complete.
|
||||||
let g:ale_fix_buffer_data[a:buffer] = {
|
let g:ale_fix_buffer_data[a:buffer] = {
|
||||||
\ 'vars': getbufvar(a:buffer, ''),
|
|
||||||
\ 'lines_before': getbufline(a:buffer, 1, '$'),
|
\ 'lines_before': getbufline(a:buffer, 1, '$'),
|
||||||
\ 'filename': expand('#' . a:buffer . ':p'),
|
|
||||||
\ 'done': 0,
|
\ 'done': 0,
|
||||||
\ 'should_save': a:fixing_flag is# 'save_file',
|
\ 'should_save': a:fixing_flag is# 'save_file',
|
||||||
\ 'temporary_directory_list': [],
|
\ 'temporary_directory_list': [],
|
||||||
|
|
|
@ -552,8 +552,6 @@ Execute(ale#fix#InitBufferData() should set up the correct data):
|
||||||
AssertEqual {
|
AssertEqual {
|
||||||
\ bufnr(''): {
|
\ bufnr(''): {
|
||||||
\ 'temporary_directory_list': [],
|
\ 'temporary_directory_list': [],
|
||||||
\ 'vars': b:,
|
|
||||||
\ 'filename': ale#path#Simplify(getcwd() . '/fix_test_file'),
|
|
||||||
\ 'done': 0,
|
\ 'done': 0,
|
||||||
\ 'lines_before': ['a', 'b', 'c'],
|
\ 'lines_before': ['a', 'b', 'c'],
|
||||||
\ 'should_save': 1,
|
\ 'should_save': 1,
|
||||||
|
|
|
@ -5,8 +5,6 @@ After:
|
||||||
unlet! g:ale_some_variable
|
unlet! g:ale_some_variable
|
||||||
unlet! b:undefined_variable_name
|
unlet! b:undefined_variable_name
|
||||||
|
|
||||||
let g:ale_fix_buffer_data = {}
|
|
||||||
|
|
||||||
Execute(ale#Var should return global variables):
|
Execute(ale#Var should return global variables):
|
||||||
AssertEqual 'abc', ale#Var(bufnr(''), 'some_variable')
|
AssertEqual 'abc', ale#Var(bufnr(''), 'some_variable')
|
||||||
|
|
||||||
|
@ -24,13 +22,3 @@ Execute(ale#Var should throw exceptions for undefined variables):
|
||||||
let b:undefined_variable_name = 'def'
|
let b:undefined_variable_name = 'def'
|
||||||
|
|
||||||
AssertThrows call ale#Var(bufnr(''), 'undefined_variable_name')
|
AssertThrows call ale#Var(bufnr(''), 'undefined_variable_name')
|
||||||
|
|
||||||
Execute(ale#Var return variables from deleted buffers, saved for fixing things):
|
|
||||||
let g:ale_fix_buffer_data[1347347] = {'vars': {'ale_some_variable': 'def'}}
|
|
||||||
|
|
||||||
AssertEqual 'def', ale#Var(1347347, 'some_variable')
|
|
||||||
|
|
||||||
Execute(ale#Var should return the global variable for unknown variables):
|
|
||||||
let g:ale_fix_buffer_data = {}
|
|
||||||
|
|
||||||
AssertEqual 'abc', ale#Var(1347347, 'some_variable')
|
|
||||||
|
|
Reference in a new issue