Skip to content

Commit ce4f3af

Browse files
author
Stephan
committed
leave alternate screen when going into external editor (fixes #152)
1 parent 80f98d6 commit ce4f3af

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/components/commit.rs

+14-3
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,27 @@ use super::{
22
textinput::TextInputComponent, visibility_blocking,
33
CommandBlocking, CommandInfo, Component, DrawableComponent,
44
};
5-
use crate::strings::COMMIT_EDITOR_MSG;
65
use crate::{
76
get_app_config_path, keys,
87
queue::{InternalEvent, NeedsUpdate, Queue},
98
strings,
9+
strings::COMMIT_EDITOR_MSG,
1010
ui::style::SharedTheme,
1111
};
1212
use anyhow::{anyhow, Result};
1313
use asyncgit::{
1414
sync::{self, CommitId},
1515
CWD,
1616
};
17-
use crossterm::event::Event;
17+
use crossterm::{
18+
event::Event,
19+
terminal::{EnterAlternateScreen, LeaveAlternateScreen},
20+
ExecutableCommand,
21+
};
22+
use scopeguard::defer;
1823
use std::env;
1924
use std::fs::File;
20-
use std::io::{Read, Write};
25+
use std::io::{self, Read, Write};
2126
use std::path::PathBuf;
2227
use std::process::Command;
2328
use strings::commands;
@@ -150,6 +155,12 @@ impl CommitComponent {
150155
anyhow!("unable to read editor command")
151156
})?;
152157

158+
io::stdout().execute(LeaveAlternateScreen)?;
159+
160+
defer! {
161+
io::stdout().execute(EnterAlternateScreen).expect("failed to reset terminal");
162+
}
163+
153164
Command::new(command)
154165
.args(editor)
155166
.status()

0 commit comments

Comments
 (0)