def BuildRequestData( buffer_number = None ):
  """Build request for the current buffer or the buffer with number
  |buffer_number| if specified."""
  working_dir = GetCurrentDirectory()
  current_buffer = vim.current.buffer

  if buffer_number and current_buffer.number != buffer_number:
    # Cursor position is irrelevant when filepath is not the current buffer.
    buffer_object = vim.buffers[ buffer_number ]
    filepath = vimsupport.GetBufferFilepath( buffer_object )
    return {
      'filepath': filepath,
      'line_num': 1,
      'column_num': 1,
      'working_dir': working_dir,
      'file_data': vimsupport.GetUnsavedAndSpecifiedBufferData( buffer_object,
                                                                filepath )
    }

  current_filepath = vimsupport.GetBufferFilepath( current_buffer )
  line, column = vimsupport.CurrentLineAndColumn()

  return {
    'filepath': current_filepath,
    'line_num': line + 1,
    'column_num': column + 1,
    'working_dir': working_dir,
    'file_data': vimsupport.GetUnsavedAndSpecifiedBufferData( current_buffer,
                                                              current_filepath )
  }
Esempio n. 2
0
def BuildRequestData(filepath=None):
    """Build request for the current buffer or the buffer corresponding to
  |filepath| if specified."""
    current_filepath = vimsupport.GetCurrentBufferFilepath()
    working_dir = GetCurrentDirectory()

    if filepath and current_filepath != filepath:
        # Cursor position is irrelevant when filepath is not the current buffer.
        return {
            'filepath': filepath,
            'line_num': 1,
            'column_num': 1,
            'working_dir': working_dir,
            'file_data': vimsupport.GetUnsavedAndSpecifiedBufferData(filepath)
        }

    line, column = vimsupport.CurrentLineAndColumn()

    return {
        'filepath': current_filepath,
        'line_num': line + 1,
        'column_num': column + 1,
        'working_dir': working_dir,
        'file_data':
        vimsupport.GetUnsavedAndSpecifiedBufferData(current_filepath)
    }