@@ -72,8 +72,7 @@ def paint(self, painter: QPainter, option: QStyleOptionViewItem, index: QModelIn
7272 if font :
7373 painter .setFont (font )
7474 fullText = index .data (Qt .ItemDataRole .DisplayRole )
75- elideMode = Qt .TextElideMode .ElideRight if settings .prefs .pathDisplayStyle == PathDisplayStyle .FileNameFirst else option .textElideMode
76- text = painter .fontMetrics ().elidedText (fullText , elideMode , textRect .width ())
75+ text = painter .fontMetrics ().elidedText (fullText , option .textElideMode , textRect .width ())
7776
7877 # Split path into directory and filename for better readability
7978 firstPortion = None
@@ -85,22 +84,10 @@ def paint(self, painter: QPainter, option: QStyleOptionViewItem, index: QModelIn
8584 isFileNameFirst = settings .prefs .pathDisplayStyle == PathDisplayStyle .FileNameFirst
8685
8786 if isFileNameFirst :
88- # Rely on the raw path to identify the filename, as filenames can contain spaces
89- fullPath = index .data (FileListModel .Role .FilePath )
90- fName = os .path .basename (fullPath )
91-
92- prefix = fName + " "
93- if not text .startswith (prefix ) and '\u2026 ' in text :
94- ellipsisPos = text .find ('\u2026 ' )
95- if fName .startswith (text [:ellipsisPos ]):
96- prefix = text [:ellipsisPos + 1 ]
97-
98- if text .startswith (prefix ):
99- firstPortion = prefix
100- secondPortion = text [len (prefix ):]
101- else :
102- firstPortion = text
103- secondPortion = ""
87+ try :
88+ firstPortion , secondPortion = text .split ('\0 ' )
89+ except ValueError :
90+ firstPortion , secondPortion = text , ""
10491
10592 firstColor = QPalette .ColorRole .WindowText
10693 secondColor = QPalette .ColorRole .PlaceholderText
@@ -236,6 +223,8 @@ def __init__(self, repoModel: RepoModel, parent: QWidget, navContext: NavContext
236223
237224 def refreshPrefs (self ):
238225 self .setVerticalScrollMode (settings .prefs .listViewScrollMode )
226+ nameFirst = settings .prefs .pathDisplayStyle == PathDisplayStyle .FileNameFirst
227+ self .setTextElideMode (Qt .TextElideMode .ElideRight if nameFirst else Qt .TextElideMode .ElideMiddle )
239228
240229 @property
241230 def repo (self ) -> Repo :
0 commit comments