Bzero / typstwriter

An integrated editor for the typst typesetting system.
Other
51 stars 2 forks source link

Open config file menu entry opens the file with an external program #20

Open NicolasCARPi opened 1 month ago

NicolasCARPi commented 1 month ago

Hello,

When clicking "Open config file" from the Settings menu, it uses open_with_external_program(), which uses xdg-open which opens it in Firefox on my system.

I would have expected it to be opened in the text editor, no?

Bzero commented 1 month ago

Hi,

I would have expected it to be opened in the text editor, no?

Yes, that's indeed the intention. I suspect this is an issue with your xdg-mime and/or desktop environment configuration which defaults to firefox for plaintext files instead of a text editor.

I am aware that the implementation of open_with_external_program is not ideal since we generally lack knowledge of the environment typstwriter is running in. If there is a more reliable way to open a file in the default application on all the different operating systems and desktop environments, I would be happy to change it.

NicolasCARPi commented 1 month ago

Oh sorry when I meant "text editor" I was thinking of typstwriter itself. BTW, you could use $EDITOR maybe to call the external editor? But that might still not work very well, for instance on my system $EDITOR is vim, but it needs to be called using urxvt...

Bzero commented 1 month ago

Oh, I see. The config file could of course be opened with typstwriter itself, however I am not sure if that has any advantages over opening it in an external text editor. Actually this would maybe raise the expectation of the new config immediately taking effect which typstwriter is not capable of as of now without restarting.

NicolasCARPi commented 1 month ago

I'd say opening the config file of the current text editor in the same current text editor seems reasonable. At least that's what I was expecting, and it might be easier to have this approach instead of trying to use xdg-open, as we've seen it is not foolproof.

If live-reloading is difficult to achieve, it is totally fine to simply show a warning that a restart of the application is necessary to take these settings into account.

Bzero commented 1 month ago

I would be fine with opening the config file in the internal editor if we add these extra warnings/notes. This would require some more work though and it might be favorable to add a proper GUI settings widget instead.

NicolasCARPi commented 1 month ago

Well, it's your decision. I was merely suggesting this. I don't think it's really important TBH, as we expect users to be able to edit a text file by themselves anyway. :)