completion.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:oil 作者: oilshell 项目源码 文件源码
def _GetNextCompletion(self, state):
    if state == 0:
      # TODO: Tokenize it according to our language.  If this is $PS2, we also
      # need previous lines!  Could make a VirtualLineReader instead of
      # StringLineReader?
      buf = readline.get_line_buffer()

      # Begin: the index of the first char of the 'word' in the line.  Words
      # are parsed according to readline delims (which we won't use).

      begin = readline.get_begidx()

      # The current position of the cursor.  The thing being completed.
      end = readline.get_endidx()

      if self.debug:
        self.status_out.Write(0,
            'line: %r / begin - end: %d - %d, part: %r', buf, begin, end,
            buf[begin:end])

      self.comp_iter = self.root_comp.Matches(buf, self.status_out)

    if self.comp_iter is None:
      self.status_out.Write(0, "ASSERT comp_iter shouldn't be None")

    try:
      next_completion = self.comp_iter.next()
    except StopIteration:
      next_completion = None  # sentinel?

    return next_completion
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号