prompt-toolkit / pyvim

Pure Python Vim clone.
BSD 3-Clause "New" or "Revised" License
2.52k stars 161 forks source link

editor_buffer.filename is not an attribute when using the config file #72

Closed smileboywtu closed 8 years ago

smileboywtu commented 8 years ago

I just install the pyvim successfully, but when I download the config file and use f9 to run the script, this error ocurrs,


# Add custom key bindings:

    @editor.add_key_binding(Keys.F9)
    def save_and_execute_python_file(event):
        """
        F9: Execute the current Python file.
        """
        # Save buffer first.
        editor_buffer = editor.current_editor_buffer

        if editor_buffer is not None:
            if editor_buffer.filename is None:
                editor.show_message("File doesn't have a filename. Please save first.")
                return
            else:
                editor_buffer.write()

erros happens at : if editor_buffer is not None: i use the fish 2.1 shell

anyone know how to config this script at fish shell?

smileboywtu commented 8 years ago

after several minutes finding in the source, I just find the code block


    def get_display_name(self, short=False):
        """
        Return name as displayed.
        """
        if self.location is None:
            return '[New file]'
        elif short:
            return os.path.basename(self.location)
        else:
            return self.location

should i use the get_display_name() to get the filename, any way I can't find the filename in the edior.py or buffer_editor.py

smileboywtu commented 8 years ago

ok, fine just change the editor_buffer.filename to editor_buffer.get_display_name()