deadpixi / sam

An updated version of the sam text editor.
Other
433 stars 47 forks source link

Sam freezes if a file generates warning #77

Closed aksr closed 6 years ago

aksr commented 6 years ago

I have a file like this:

$ file test
 test: Little-endian UTF-16 Unicode text, with CRLF, CR line terminators

Hitting q immediately when sam is started, causes sam to freeze.

I'm not sure but, I think sam generates warning message as soon as it's started (even though warning message isn't shown), I don't think it's related to encoding and/or line terminators. Encoding and etc. are only important while they cause sam to generate warning.

In short, if the file generates warning message as soon as it's started with sam (e.g. sam testfile), but not open, hitting q key will cause freeze.

ckeen commented 6 years ago

Can you paste a file that does trigger this?

aksr commented 6 years ago

Because of the encoding and/or line terminators, it isn't possible to paste this kind of file.

aksr commented 6 years ago

Let me see to upload it somewhere, so you can confirm this, if it's okay?

ckeen commented 6 years ago

Can you pipe the file through hexdump -x and paste this? I just want to make sure I am trying the right thing.

aksr commented 6 years ago

Here: https://uploadfiles.io/yybju

ckeen commented 6 years ago

What I am seeing there: when I hit q immediately, sometimes the file still wants to get placed, i.e. the curser changes to the resize cursor.

In this mode sam does not accept any comand until the file has been reshaped or the reshaping is aborted.

Is that the case on your side too?

aksr commented 6 years ago

Yes.

aksr commented 6 years ago

Hm, normal files don't demand to be placed (before quitting)—that seems strange, I haven't noticed cursor (while it was hidden.).

ckeen commented 6 years ago

Indeed, I suspect some race for input due to the issued warning... @deadpixi What do you think?

deadpixi commented 6 years ago

@ckeen @aksr

Sorta-kinda there's a race condition, yeah.

sam removes nulls from file content for various reasons. When it does so, it more-or-less marks the file as modified, which sets the global quitok variable to false and hilarity ensues.

I've gone ahead and made it such that the presences of nulls is not itself sufficient to block quitting; you'll still get a warning.

This doesn't fix the similar issue of read error on load (e.g. if the file doesn't exist). That's more difficult to fix cleanly. I'll keep working on it, but I'll close this issue for now. Please, @aksr, reopen it if the code in master doesn't address this issue.

deadpixi commented 6 years ago

@aksr @ckeen I also just overhauled (well, started to), the IO subsystem. The code is in master, if you'd be so kind as to try it out. :)

aksr commented 6 years ago

It seems the bug is fixed.