pulsar-edit / pulsar

A Community-led Hyper-Hackable Text Editor
https://pulsar-edit.dev
Other
3.19k stars 133 forks source link

Pulsar got closed by itself if I close the external terminal #979

Open zhaolinlau opened 4 months ago

zhaolinlau commented 4 months ago

Thanks in advance for your bug report!

What happened?

When I open a project through terminal using pulsar ., it does open the project with pulsar, but after that I close the terminal, at the same time the pulsar will be closed if I close the terminal.

Pulsar version

1.116.0

Which OS does this happen on?

🪟 Windows

OS details

11

Which CPU architecture are you running this on?

x86_64/AMD64

What steps are needed to reproduce this?

  1. manually add Pulsar to PATH
  2. open a terminal
  3. open a project through terminal using pulsar .
  4. now the project will be opened with pulsar
  5. close the terminal
  6. once the terminal being closed, it will auto close the pulsar

Additional Information:

No response

confused-Techie commented 4 months ago

Thanks a ton for reporting this!

But, and someone feel free to correct me if I'm wrong, pretty sure this is expected behavior. When launching Pulsar from the command line that session then essentially owns the child process that is Pulsar.

So when the parent process is killed then of course it'll kill any child process'.

If it helps you can work around this within Windows itself by using something like pulsar . & exit which will launch Pulsar then immediately exit the shell for you, while keeping Pulsar running.

But otherwise I'm not sure if there's that much that can be done on our end to configure this behavior.

savetheclocktower commented 4 months ago

I'm betting that this is new behavior because @zhaolinlau has opened issues against this repo before and has probably used versions prior to 1.116.

@zhaolinlau, is this something that was behaving differently on Windows before 1.116?

zhaolinlau commented 4 months ago

I'm betting that this is new behavior because @zhaolinlau has opened issues against this repo before and has probably used versions prior to 1.116.

@zhaolinlau, is this something that was behaving differently on Windows before 1.116?

Actually this is not a new behaviour, this issue occurred since the first release of the pulsar.

savetheclocktower commented 4 months ago

OK, cool. Thanks for the report.

Windows users: I'm curious if VSCode has the same behavior. If not, then it's within our ability to fix.

zhaolinlau commented 4 months ago

Thanks a ton for reporting this!

But, and someone feel free to correct me if I'm wrong, pretty sure this is expected behavior. When launching Pulsar from the command line that session then essentially owns the child process that is Pulsar.

So when the parent process is killed then of course it'll kill any child process'.

If it helps you can work around this within Windows itself by using something like pulsar . & exit which will launch Pulsar then immediately exit the shell for you, while keeping Pulsar running.

But otherwise I'm not sure if there's that much that can be done on our end to configure this behavior.

Well this shouldn't be an expected behaviour because Atom and VsCodium don't have this issue.

savetheclocktower commented 4 months ago

It's also not the behavior of Pulsar or Atom on macOS or (I think) Linux, so we should aim for uniformity here.

confused-Techie commented 4 months ago

So just checking this isn't the behavior on Atom's last released versions.

Although, launching Atom via the CLI also doesn't provide any output to the console of what's going on, unlike Pulsar which does show significant output.

I think it's the fact that we continually log output to the console that's doing us in. Unless we also do that on other platforms and it doesn't cause it to close there.

DeeDeeG commented 4 months ago

Maybe it's something to do with how electron-builder packages Pulsar, compared to how Atom or VS Code / vscodium are packaged.

Or perhaps Atom adds some launcher batch (.bat) script to the PATH, instead of the actual Electron binary as we're doing? I'm pretty sure Node and npm are usually added to PATH as batch (.bat)/powershell (.ps1) scripts, maybe there's a reason for it.

EDIT: It should be launching this, I believe: https://github.com/pulsar-edit/pulsar/blob/master/resources/win/pulsar.cmd

So we should make sure this .cmd script is what's being added to the PATH, and that the logic in the .cmd script properly allows the terminal to close without exiting Pulsar itself.

confused-Techie commented 4 months ago

@DeeDeeG Looking into the .bat is a great idea, although I'll say it's probably not the fault of electron-builder as the output looks and behaves identical when running Pulsar for development via the CLI. So maybe it is possible we are having Pulsar be run as the EXE rather than the .bat


EDIT:

So running pulsar --version on my Windows shell after disabling @echo off in the pulsar.bat it does appear we are successfully utilizing the .bat file when running via the command line.

So seems extra strange this would break things as I don't think we've changed much of this file. Actually checking the exact diffs between pulsar.cmd and atom.cmd the only change is in the name and location of the final EXE to launch. So the fault isn't of this file explicitly.