From eb18b57463e32b6d3e5d8be4793a83c95acce5f4 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 21 Oct 2015 20:45:29 +0530 Subject: [PATCH] Edit Book File List: Fix pre-selection of filename when renaming a file in the root --- src/calibre/gui2/tweak_book/file_list.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/calibre/gui2/tweak_book/file_list.py b/src/calibre/gui2/tweak_book/file_list.py index c7dc18ed9f..375d13cc41 100644 --- a/src/calibre/gui2/tweak_book/file_list.py +++ b/src/calibre/gui2/tweak_book/file_list.py @@ -99,7 +99,9 @@ class ItemDelegate(QStyledItemDelegate): # {{{ editor.setText(name) ext_pos = name.rfind('.') slash_pos = name.rfind('/') - if ext_pos > -1 and slash_pos > -1 and ext_pos > slash_pos + 1: + if slash_pos == -1 and ext_pos > 0: + editor.setSelection(0, ext_pos) + elif ext_pos > -1 and slash_pos > -1 and ext_pos > slash_pos + 1: editor.setSelection(slash_pos+1, ext_pos - slash_pos - 1) else: editor.selectAll()