From b36d0047bc7012b387abf775d25078b4195b83e5 Mon Sep 17 00:00:00 2001
From: wangxiaoqing <wangxiaoqing@kylinsec.com.cn>
Date: Wed, 27 Jul 2022 17:49:59 +0800
Subject: [PATCH 1/4] Fix the file can be rename to only container space name
 file
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

- 修复重命名文件和文件夹时只输入空格，文件命名成了空文件名
  Related #I5I8KI

Signed-off-by: wangxiaoqing <wangxiaoqing@kylinsec.com.cn>
---
 libcaja-private/caja-icon-container.c | 4 +++-
 src/file-manager/fm-list-view.c       | 5 ++++-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/libcaja-private/caja-icon-container.c b/libcaja-private/caja-icon-container.c
index 5de4ac3..9a2c3e8 100644
--- a/libcaja-private/caja-icon-container.c
+++ b/libcaja-private/caja-icon-container.c
@@ -9132,7 +9132,9 @@ end_renaming_mode (CajaIconContainer *container, gboolean commit)
 
         /* Verify that text has been modified before signalling change. */
         changed_text = eel_editable_label_get_text (EEL_EDITABLE_LABEL (container->details->rename_widget));
-        if (strcmp (container->details->original_text, changed_text) != 0)
+        if (strlen (changed_text) > 0 &&
+	    strcmp (container->details->original_text, changed_text) != 0 &&
+            strncmp (changed_text, " ", 1) != 0)
         {
             AtkObject *accessible_icon;
 
diff --git a/src/file-manager/fm-list-view.c b/src/file-manager/fm-list-view.c
index bfc29c2..6339a1c 100644
--- a/src/file-manager/fm-list-view.c
+++ b/src/file-manager/fm-list-view.c
@@ -1402,7 +1402,10 @@ cell_renderer_edited (GtkCellRendererText *cell,
                         -1);
 
     /* Only rename if name actually changed */
-    if (strcmp (new_text, view->details->original_name) != 0)
+    if (strlen (new_text) > 0 &&
+        strcmp (new_text, view->details->original_name) != 0 &&
+        strncmp (new_text, " ", 1) != 0)
+
     {
         view->details->renaming_file = caja_file_ref (file);
         view->details->rename_done = FALSE;
-- 
2.36.1

