show symbolic link in rootnode dir

This commit is contained in:
Amber 2024-02-07 14:42:48 +01:00
parent c7b65b9d78
commit 307bc5a15f
2 changed files with 15 additions and 5 deletions

View File

@ -26,8 +26,8 @@ class NerdTree():
if path_object.is_dir():
item_type = 'd'
elif path_object.is_symlink():
item_type = 'l'
# elif path_object.is_symlink():
# item_type = 'l'
elif path_object.is_file():
item_type = 'f'
@ -81,7 +81,8 @@ class NerdTree():
start_dir_item_type, start_dir_object = self.get_path_obj(startpath)
stat_dir_item = start_dir_object.lstat()
start_dir_target = start_dir_object.resolve() if start_dir_object.is_symlink() else ''
start_dir_is_symlink = start_dir_object.is_symlink()
start_dir_target = start_dir_object.resolve() if start_dir_is_symlink else ''
if path:
path.append({
@ -90,6 +91,7 @@ class NerdTree():
'abs_path' : startpath,
'size' : stat_dir_item.st_size,
'target' : str(start_dir_target),
'is_symlink' : start_dir_is_symlink,
})
else:
path = [{
@ -98,6 +100,7 @@ class NerdTree():
'abs_path' : startpath,
'size' : stat_dir_item.st_size,
'target' : str(start_dir_target),
'is_symlink' : start_dir_is_symlink,
}]
d = {
@ -108,6 +111,7 @@ class NerdTree():
'path': path,
'size' : stat_dir_item.st_size,
'target' : str(start_dir_target),
'is_symlink' : start_dir_is_symlink,
}
# using listdir
@ -130,7 +134,8 @@ class NerdTree():
if path_object.is_dir():
d['children'].append(self.tree_struct(abs_path_item, path=path[:]))
else:
target = path_object.resolve() if path_object.is_symlink() else ''
is_symlink = path_object.is_symlink()
target = path_object.resolve() if is_symlink else ''
path_copy = path[:]
path_copy.append({
@ -138,6 +143,7 @@ class NerdTree():
'type' : item_type,
'abs_path' : abs_path_item,
'target' : str(target),
'is_symlink' : is_symlink,
})
d['children'].append({
@ -147,6 +153,7 @@ class NerdTree():
'path' : path_copy,
'size' : stat_item.st_size,
'target' : str(target),
'is_symlink' : is_symlink,
})
return d
@ -199,6 +206,9 @@ class NerdTree():
else:
nerd_tree_txt = rootnode_name
if (rootnode['is_symlink'] and rootnode.get('target', '')):
nerd_tree_txt += ' -> %s' % (rootnode['target'],)
nodefound = rootnode.get('found')
if nodefound and self.opts['dont_show_children_nodes']:
if rootnode.get('subtree_items'):

View File

@ -43,7 +43,7 @@ def produce_treeline(prec_seps, lsep):
item_name = item['name']
tomount = sep + item_name
if item.get('type') == 'l' and item.get('target', ''):
if item.get('is_symlink') and item.get('target', ''):
tomount += ' -> %s' % ((item['target'],))
# if item.get('type') == 'd':