# Re: \[PATCH\] editor: only save (and restore) the terminal if using a tty

- From: Johannes Schindelin \<hidden\>
- Date: 2021-12-02 14:48:58 
- List: git
- Page: https://ratatoskr.run/git/2021/12/7913723
- Thread: https://ratatoskr.run/git/2021/11/7912794/t.md

```text
Hi Chris,

On Tue, 30 Nov 2021, Chris Torek wrote:

> On Tue, Nov 30, 2021 at 2:41 PM Phillip Wood [ref] wrote:
> > On 23/11/2021 17:31, Carlo Arenas wrote:
> > > Restricting this feature further, maybe through a configuration
> > > property or even special casing the EDITOR is also IMHO a good idea.
> >
> > I think just doing this when we run the editor may be the way to go as I
> > think it is only that case that can mess up the terminal.
>
> If it only happens with certain versions of vi / vim, perhaps Git could come
> with a front end program that saves the tty state, runs vim, and restores the
> tty state. (Or set this up so that the program can run any editor.)  Then add
> a FAQ entry if needed: "if your editor goofs up the terminal, insert this front
> end program".

Putting myself into an end-user's shoes, I would much prefer not to be
asked to do extra work and I imagine that the millions of other users who
go with Git's default editor have the very same preference.

Just like we default to `LESS=FRX` for Git's default pager, and just like
we special-case `less` and `vi` in `git grep -O<program>`, it makes sense
to special-case `vi` when saving/restoring the terminal because we know it
helps users.

And by "special-case", I want to say that Git should provide a paved path
to success, not a workaround that users still have to configure manually.

Ciao,
Dscho
```
