project_panel: Do not allow creating empty file/dir or file/dir with only whitespaces (#28240)
- Do not allow creating empty file or empty directory. - Do not allow creating file or directory with just whitespace. - Show error only in case whitespace. <img width="352" alt="image" src="https://github.com/user-attachments/assets/f6040332-59a6-4d09-bf07-2b4b1b8b9e03" /> Release Notes: - N/A
This commit is contained in:
parent
c21fdd212b
commit
7ee9109ade
2 changed files with 66 additions and 16 deletions
|
@ -766,6 +766,50 @@ async fn test_editing_files(cx: &mut gpui::TestAppContext) {
|
|||
" .dockerignore",
|
||||
]
|
||||
);
|
||||
|
||||
// Test empty filename and filename with only whitespace
|
||||
panel.update_in(cx, |panel, window, cx| panel.new_file(&NewFile, window, cx));
|
||||
assert_eq!(
|
||||
visible_entries_as_strings(&panel, 0..10, cx),
|
||||
&[
|
||||
"v root1",
|
||||
" > .git",
|
||||
" > a",
|
||||
" v b",
|
||||
" > 3",
|
||||
" > 4",
|
||||
" > new-dir",
|
||||
" [EDITOR: ''] <== selected",
|
||||
" a-different-filename.tar.gz",
|
||||
" > C",
|
||||
]
|
||||
);
|
||||
panel.update_in(cx, |panel, window, cx| {
|
||||
panel.filename_editor.update(cx, |editor, cx| {
|
||||
editor.set_text("", window, cx);
|
||||
});
|
||||
assert!(panel.confirm_edit(window, cx).is_none());
|
||||
panel.filename_editor.update(cx, |editor, cx| {
|
||||
editor.set_text(" ", window, cx);
|
||||
});
|
||||
assert!(panel.confirm_edit(window, cx).is_none());
|
||||
panel.cancel(&menu::Cancel, window, cx)
|
||||
});
|
||||
assert_eq!(
|
||||
visible_entries_as_strings(&panel, 0..10, cx),
|
||||
&[
|
||||
"v root1",
|
||||
" > .git",
|
||||
" > a",
|
||||
" v b",
|
||||
" > 3",
|
||||
" > 4",
|
||||
" > new-dir",
|
||||
" a-different-filename.tar.gz <== selected",
|
||||
" > C",
|
||||
" .dockerignore",
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
#[gpui::test(iterations = 10)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue