Skip to content

Commit

Permalink
Use the jumplist instead of a custom stack.
Browse files Browse the repository at this point in the history
  • Loading branch information
xavierd committed Mar 4, 2013
1 parent 637d2bb commit cdf98a5
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 27 deletions.
10 changes: 1 addition & 9 deletions plugin/clang_complete.vim
Expand Up @@ -140,7 +140,7 @@ function! s:ClangCompleteInit()
inoremap <expr> <buffer> : <SID>CompleteColon()
inoremap <expr> <buffer> <CR> <SID>HandlePossibleSelectionEnter()
nnoremap <buffer> <silent> <C-]> :call <SID>GotoDeclaration()<CR>
nnoremap <buffer> <silent> <C-T> :call <SID>GotoBack()<CR>
nnoremap <buffer> <silent> <C-T> <C-O>
if g:clang_snippets == 1
call g:ClangSetSnippetEngine(g:clang_snippets_engine)
Expand Down Expand Up @@ -459,18 +459,10 @@ function! s:CompleteColon()
endfunction

function! s:GotoDeclaration()
" I would like to mimic <C-]> and <C-T> when using tags.
" It would be much easier if the tag stack could be modified, but alas
" that is not possible. All the handling should be done by hand...
python gotoDeclaration()
return ''
endfunction

function! s:GotoBack()
python gotoBack()
return ''
endfunction

" May be used in a mapping to update the quickfix window.
function! g:ClangUpdateQuickFix()
call s:DoPeriodicQuickFix()
Expand Down
18 changes: 0 additions & 18 deletions plugin/libclang.py
Expand Up @@ -89,8 +89,6 @@ def initClangComplete(clang_complete_flags, clang_compilation_database, \
compilation_database = None
global libclangLock
libclangLock = threading.Lock()
global jumpStack
jumpStack = []
return 1

# Get a tuple (fileName, fileContent) for the file opened in the current
Expand Down Expand Up @@ -500,16 +498,6 @@ def getAbbr(strings):
return chunks.spelling
return ""

def pushLocation(loc):
global jumpStack
jumpStack.append((loc.file.name, loc.line, loc.column))

def popLocation():
if jumpStack == []:
print "Empty jump stack!"
return (None, 0, 0)
return jumpStack.pop()

def jumpToLocation(filename, line, column):
if filename != vim.current.buffer.name:
vim.command("edit! %s" % filename)
Expand All @@ -531,17 +519,11 @@ def gotoDeclaration():
loc = SourceLocation.from_position(tu, f, line, col + 1)
cursor = Cursor.from_location(tu, loc)
if cursor.referenced is not None and loc != cursor.referenced.location:
pushLocation(loc)
loc = cursor.referenced.location
jumpToLocation(loc.file.name, loc.line, loc.column)

timer.finish()

def gotoBack():
filename, line, column = popLocation()
if filename is not None:
jumpToLocation(filename, line, column)

# Manually extracted from Index.h
# Doing it by hand is long, error prone and horrible, we must find a way
# to do that automatically.
Expand Down

0 comments on commit cdf98a5

Please sign in to comment.