def update_xpos(self, force=False):
if self.must_update_xpos or force:
try:
# TODO: we should check the current mode instead. ============
sel = self.view.sel()[0]
pos = sel.b
if not sel.empty():
if sel.a < sel.b:
pos -= 1
# ============================================================
r = sublime.Region(self.view.line(pos).a, pos)
counter = Counter(self.view.substr(r))
tab_size = self.view.settings().get('tab_size')
xpos = (self.view.rowcol(pos)[1] +
((counter['\t'] * tab_size) - counter['\t']))
except Exception as e:
nvim.console_message(e)
_logger.exception('error setting xpos; default to 0')
self.xpos = 0
return
else:
self.xpos = xpos
评论列表
文章目录