Changeset - 58a4004224a2
[Not reviewed]
beta
0 1 0
Marcin Kuzminski - 13 years ago 2013-01-05 03:30:24
marcin@python-works.com
fixes issue #710 File view stripping empty lines from begininng and end of the file. Fixed by setting default Pygment lexer option to not do that
1 file changed with 3 insertions and 2 deletions:
0 comments (0 inline, 0 general)
rhodecode/lib/vcs/nodes.py
Show inline comments
 
@@ -341,52 +341,53 @@ class FileNode(Node):
 
                mtype = 'text/plain'
 
                encoding = None
 
        return mtype, encoding
 

	
 
    @LazyProperty
 
    def mimetype(self):
 
        """
 
        Wrapper around full mimetype info. It returns only type of fetched
 
        mimetype without the encoding part. use get_mimetype function to fetch
 
        full set of (type,encoding)
 
        """
 
        return self.get_mimetype()[0]
 

	
 
    @LazyProperty
 
    def mimetype_main(self):
 
        return ['', '']
 
        return self.mimetype.split('/')[0]
 

	
 
    @LazyProperty
 
    def lexer(self):
 
        """
 
        Returns pygment's lexer class. Would try to guess lexer taking file's
 
        content, name and mimetype.
 
        """
 

	
 
        try:
 
            lexer = lexers.guess_lexer_for_filename(self.name, self.content)
 
            lexer = lexers.guess_lexer_for_filename(self.name, self.content, stripnl=False)
 
        except lexers.ClassNotFound:
 
            lexer = lexers.TextLexer()
 
            lexer = lexers.TextLexer(stripnl=False)
 
        # returns first alias
 
        return lexer
 

	
 
    @LazyProperty
 
    def lexer_alias(self):
 
        """
 
        Returns first alias of the lexer guessed for this file.
 
        """
 
        return self.lexer.aliases[0]
 

	
 
    @LazyProperty
 
    def history(self):
 
        """
 
        Returns a list of changeset for this file in which the file was changed
 
        """
 
        if self.changeset is None:
 
            raise NodeError('Unable to get changeset for this FileNode')
 
        return self.changeset.get_file_history(self.path)
 

	
 
    @LazyProperty
 
    def annotate(self):
 
        """
 
        Returns a list of three element tuples with lineno,changeset and line
 
        """
0 comments (0 inline, 0 general)