Skip to content

Commit

Permalink
fix bug for ctags bytes vs str
Browse files Browse the repository at this point in the history
  • Loading branch information
fengidri committed Feb 4, 2020
1 parent 16cdd9e commit 8200b6b
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 19 deletions.
2 changes: 1 addition & 1 deletion exts/goany/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import filter_tag
import filter_file
import all_tag
#import tags
import tags


import pyvim
Expand Down
2 changes: 2 additions & 0 deletions exts/goany/filter_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ def __init__(self, path):

def quit(self, win, index):
file_filter.INSTANCE = None
if not index:
return

if index > -1:
path = os.path.join(self.path, self.fs[index])
Expand Down
40 changes: 25 additions & 15 deletions exts/goany/tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ def encode(cmd):


def goto(path, prefix, pos):

logging.error('goto path: %s, %s, %s' %(path, prefix, pos))

if path != vim.current.buffer.name:
vim.command('update')

Expand All @@ -37,9 +40,9 @@ def goto(path, prefix, pos):
tagname = prefix[1]

line_nu = None
if isinstance(line, basestring):
if isinstance(line, str):
for i, l in enumerate(vim.current.buffer):
if l.startswith(line):
if l.startswith(line[2:-1]):
line_nu = i
else:
line_nu = line
Expand Down Expand Up @@ -79,22 +82,27 @@ def goto(self):

class Tag(object):
def __init__(self, root, entry):
self.tag = entry["name"]
self.file_path = os.path.join(root, entry["file"])
self.tag = entry[b"name"]

root = bytes(root, encoding="utf-8")

line = entry["pattern"]
self.file_path = os.path.join(root, entry[b"file"])

line = entry[b"pattern"]
if line.isdigit():
self.line = int(line) - 1
else:
patten = line.replace(r'\/','/')
line = str(line)
patten = line.replace(r'\/', '/')
patten = patten.replace(r'\r','')
self.line = encode(patten[2:-2])

self.line_num = entry["lineNumber"]
self.kind = entry["kind"]
self.line_num = entry[b"lineNumber"]
self.kind = entry[b"kind"]

def goto(self):
goto(self.file_path, (self.line, self.tag), None)
goto(self.file_path.decode('utf8'),
(self.line, self.tag.decode('utf8')), None)



Expand All @@ -119,7 +127,7 @@ def open(self):
self.funs = None

self.tagsfile = tags;
self.tagfile = ctags.CTags(self.tagsfile)
self.tagfile = ctags.CTags(bytes(self.tagsfile, encoding='utf-8'))
self.entry = ctags.TagEntry()
return True

Expand Down Expand Up @@ -163,7 +171,7 @@ def out_list(self, tag, MODE=ctags.TAG_FULLMATCH):
return None

list_tags = []
status = self.tagfile.find(self.entry, tag, MODE )
status = self.tagfile.find(self.entry, bytes(tag, encoding='utf-8'), MODE )
if not status:
return None

Expand Down Expand Up @@ -248,10 +256,12 @@ def jump_tag(self):
return 0

#echo
vim.command("echo '%s %s %s/%s'" % (
frame.tagname,
frame.taglist[frame.index].kind,
frame.index, frame.num))
#cmd = "echo '%s %s %s/%s'" % ( frame.tagname,
# frame.taglist[frame.index].kind,
# frame.index, frame.num)

#print(cmd)
#vim.command(cmd)

self.goto(frame)

Expand Down
2 changes: 0 additions & 2 deletions exts/web/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ def start():
curfile = os.path.realpath(__file__)
curdir = os.path.dirname(curfile)
fwebdir = os.path.join(curdir, 'fweb')
subprocess.call(['bash', '-c',
'cd %s; python2 fweb.py >/dev/null 2>&1' % fwebdir])


start()
Expand Down
1 change: 0 additions & 1 deletion wind/pyvim/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ def __command(vimcmd, fun, complete):
index=len(CMDS))

CMDS.append(fun)
logging.debug(c)
vim.command(c)


Expand Down

0 comments on commit 8200b6b

Please sign in to comment.