face-hh / fextify

A simple text editor written in Rust using Tauri, inspired by Obsidian.
Apache License 2.0
197 stars 14 forks source link

bug(main): Rename failed, attempted creation successful. #2

Open FormalSnake opened 10 months ago

FormalSnake commented 10 months ago

So there is a path system, but it uses the C drive, which is not doable on mac. This could be done by getting the system document folder, but idk in rust.

lazy_static! {
    static ref PATH: Mutex<String> = Mutex::new("C:/Users/User/Documents/GitHub/text-editor/Folder".to_string());
}
FormalSnake commented 10 months ago

https://tauri.app/v1/api/js/path/#documentdir

face-hh commented 10 months ago

That's a placeholder, you can assume the string is empty. It will fail to read the document regardless of its initial value.

You did however remind me that I've forgot some few if statements while writing the latest commit; I've now added a check to prevent the reset of the config.json file:

let exists = &dir.join("config.json").exists();

About MacOS support, I'm not sure if the code will compile there since the very first line of code is:

#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]

I'd be happy to adjust the code to work on Mac if someone will open an issue with the error stack from MacOS

FormalSnake commented 10 months ago

I will do that in a few hours, I am going to watch FNAF lol 🤣

creeperita09 commented 10 months ago

ima help you and send the stack trace in like 10 mins

FormalSnake commented 10 months ago

So, using bun run dev it worked! But there seems to be an issue with saving files.

Created config folder in AppData
(MINOR) Child with id not found: 0
(MINOR) Child with id not found: 2321c09016c1b6e
Renamed "Untitled 2321c09016c1b6e.md" to "H.md"
Renamed "H.md" to "He.md"
Renamed "He.md" to "Hel.md"
Renamed "Hel.md" to "Hell.md"
Renamed "Hell.md" to "Hello.md"
(MINOR) Child with id not found: 4e0e21e66fe6e04
Renamed "Untitled 4e0e21e66fe6e04.md" to "H.md"
Renamed "H.md" to "He.md"
Renamed "He.md" to "Hel.md"
Renamed "Hel.md" to "Hell.md"
Renamed "Hell.md" to "Hello.md"
Renamed "Hello.md" to "Hello .md"
Renamed "Hello .md" to "Hello t.md"
Renamed "Hello t.md" to "Hello th.md"
Renamed "Hello th.md" to "Hello the.md"
Renamed "Hello the.md" to "Hello ther.md"
Renamed "Hello ther.md" to "Hello there.md"
Renamed "Hello there.md" to "Hello there!.md"
Rename failed, attempted creation successful.
Renamed "H.md" to "Hi.md"
Couldn't find child with path: H.md
Renamed "Hi.md" to "Hi!.md"
Couldn't find child with path: Hi.md
face-hh commented 10 months ago

Could you try replicating the issue, but only using alphabetical characters in the title? Seems like the error occurred when you inserted "!".

FormalSnake commented 10 months ago

It works, but the issue is that the first tab doesn't work, it doesn't save.

FormalSnake commented 10 months ago

Renamed ".md" to "f.md" Couldn't find child with path: .md Renamed "f.md" to "fi.md" Couldn't find child with path: f.md Renamed "fi.md" to "fir.md" Couldn't find child with path: fi.md Renamed "fir.md" to "firs.md" Couldn't find child with path: fir.md Renamed "firs.md" to "first.md" Couldn't find child with path: firs.md Renamed "first.md" to "firstt.md" Couldn't find child with path: first.md Renamed "firstt.md" to "firstta.md" Couldn't find child with path: firstt.md Renamed "firstta.md" to "firsttab.md" Couldn't find child with path: firstta.md Renamed "firsttab.md" to "First tab.md" Couldn't find child with path: firsttab.md

face-hh commented 10 months ago

It works, but the issue is that the first tab doesn't work, it doesn't save.

That's since it failed once and lost the path forever. To temporarily fix this, you can delete your config.json.

If you take a look at %APPDATA%/Fextify/Data/data/ (may be different on MacOS) you'll see that it's currently being spammed by files.

If you wish, once you empty your config.json, you can follow some debugging steps I've previously provided:

Could you try replicating the issue, but only using alphabetical characters in the title? Seems like the error occurred when you inserted "!".

FormalSnake commented 10 months ago

What is that on mac? It is not in Application Support which should be the mac version of %appdata%

face-hh commented 10 months ago

What is that on mac? It is not in Application Support which should be the mac version of %appdata%

I'm unsure, but you can modify src-tauri/src/main.rs at line 46 to be:

println!("{:?}", dir);

Then you can recompile the program on dev (npm run tauri dev), and check the terminal for the path to be printed.

I will reopen this issue until the issue gets resolved.