fix: stop treating .txt as a supported document
Plain text was listed in the open, locate and link handlers but the file dialog never offered it for new files, and a .txt opened through the app behaved like Markdown without being one. Drop the extension everywhere so the supported set is one list: md, markdown, mdown, mkd.
This commit is contained in:
16
src/main.rs
16
src/main.rs
@@ -2797,6 +2797,16 @@ mod tests {
|
||||
assert!(html.contains("<hr />"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn only_markdown_extensions_are_supported_documents() {
|
||||
for name in ["note.md", "note.MARKDOWN", "note.mdown", "note.mkd"] {
|
||||
assert!(is_supported_document(Path::new(name)), "{name}");
|
||||
}
|
||||
for name in ["note.txt", "note.html", "note", "note.md.bak"] {
|
||||
assert!(!is_supported_document(Path::new(name)), "{name}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn file_urls_only_open_existing_supported_documents() {
|
||||
let dir = temp_test_dir("document-links");
|
||||
@@ -3824,7 +3834,7 @@ fn is_supported_document(path: &Path) -> bool {
|
||||
.map(|extension| {
|
||||
matches!(
|
||||
extension.to_string_lossy().to_ascii_lowercase().as_str(),
|
||||
"md" | "markdown" | "mdown" | "mkd" | "txt"
|
||||
"md" | "markdown" | "mdown" | "mkd"
|
||||
)
|
||||
})
|
||||
.unwrap_or(false)
|
||||
@@ -4947,7 +4957,7 @@ fn main() {
|
||||
return;
|
||||
}
|
||||
if let Some(paths) = rfd::FileDialog::new()
|
||||
.add_filter("Markdown", &["md", "markdown", "mdown", "mkd", "txt"])
|
||||
.add_filter("Markdown", &["md", "markdown", "mdown", "mkd"])
|
||||
.pick_files()
|
||||
{
|
||||
let _ = proxy.send_event(UserEvent::OpenPaths(
|
||||
@@ -5190,7 +5200,7 @@ fn main() {
|
||||
}
|
||||
TaoEvent::UserEvent(UserEvent::LocateTab(window_id, id)) => {
|
||||
if let Some(path) = rfd::FileDialog::new()
|
||||
.add_filter("Markdown", &["md", "markdown", "mdown", "mkd", "txt"])
|
||||
.add_filter("Markdown", &["md", "markdown", "mdown", "mkd"])
|
||||
.pick_file()
|
||||
{
|
||||
if let Some((other_id, other_tab)) = find_open_path(&app, &path) {
|
||||
|
||||
Reference in New Issue
Block a user