Skip to content
This repository has been archived by the owner on Sep 12, 2022. It is now read-only.

Major fixes, among them windows file handling #44

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion pythonx/netranger/netranger.py
Original file line number Diff line number Diff line change
Expand Up @@ -1091,9 +1091,33 @@ class Netranger(object):
1. BufEnter: on_bufenter. create/update NetRangerBuf.
2. CursorMoved: on_cursormoved. update node highlighting and some othe stuff.
"""
def generate_and_ret_buf(self):
bufname = Vim.current.buffer.name
if len(bufname) > 0 and bufname[-1] == '~':
bufname = os.path.expanduser('~')
if not os.path.isdir(bufname):
return
if os.path.islink(bufname):
bufname = os.path.join(os.path.dirname(bufname),
os.readlink(bufname))
bufname = os.path.abspath(bufname)

# if self.buf_existed(bufname):
# self._bufs[Vim.current.buffer.number] = self._wd2bufnum[bufname]
# else:
self.gen_new_buf(bufname)

return self._bufs[Vim.current.buffer.number]




@property
def cur_buf(self):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you elaborate what issues you encountered. We already have a a gen_new_buf function called by on_bufenter, which should guarantee that all call to cur_buf to be valid.

return self._bufs[Vim.current.buffer.number]
if Vim.current.buffer.number in self._bufs:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you encounter a key not found error here?

return self._bufs[Vim.current.buffer.number]
else:
return self.generate_and_ret_buf()

@property
def cur_node(self):
Expand Down