mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-31 03:51:14 -03:00
Be more consistent about when to query the TTY
We are more conservative with querying on startup than we are with querying for cursor position. Part of this is oversight (if startup querying is not done, we basically never get into a position where we query for cursor position, outside extreme edge cases). Also, some specific scenarios where we query for cursor position inside, say, Midnight Commander, are not actually broken, because that only happens when Midnight Commander gives us control. But let's favor consistency for now; the Midnight Commander issue should be fixed soon anyway. Use the same logic in both cases.
This commit is contained in:
@@ -259,6 +259,10 @@ fn redirect_tty_after_sighup() {
|
||||
}
|
||||
}
|
||||
|
||||
fn querying_allowed() -> bool {
|
||||
!is_dumb() && std::env::var_os("MC_TMPDIR").is_none() && isatty(STDOUT_FILENO)
|
||||
}
|
||||
|
||||
pub(crate) fn initial_query(
|
||||
blocking_query: &OnceCell<RefCell<Option<TerminalQuery>>>,
|
||||
out: &mut impl Output,
|
||||
@@ -266,19 +270,18 @@ pub(crate) fn initial_query(
|
||||
) {
|
||||
blocking_query.get_or_init(|| {
|
||||
initialize_tty_metadata();
|
||||
let query =
|
||||
if is_dumb() || std::env::var_os("MC_TMPDIR").is_some() || !isatty(STDOUT_FILENO) {
|
||||
None
|
||||
} else {
|
||||
// Query for kitty keyboard protocol support.
|
||||
out.write_command(QueryKittyKeyboardProgressiveEnhancements);
|
||||
out.write_command(QueryXtversion);
|
||||
if let Some(vars) = vars {
|
||||
query_capabilities_via_dcs(out.by_ref(), vars);
|
||||
}
|
||||
out.write_command(QueryPrimaryDeviceAttribute);
|
||||
Some(TerminalQuery::Initial)
|
||||
};
|
||||
let query = if !querying_allowed() {
|
||||
None
|
||||
} else {
|
||||
// Query for kitty keyboard protocol support.
|
||||
out.write_command(QueryKittyKeyboardProgressiveEnhancements);
|
||||
out.write_command(QueryXtversion);
|
||||
if let Some(vars) = vars {
|
||||
query_capabilities_via_dcs(out.by_ref(), vars);
|
||||
}
|
||||
out.write_command(QueryPrimaryDeviceAttribute);
|
||||
Some(TerminalQuery::Initial)
|
||||
};
|
||||
RefCell::new(query)
|
||||
});
|
||||
}
|
||||
@@ -1542,7 +1545,7 @@ pub(crate) fn blocking_query(&self) -> RefMut<'_, Option<TerminalQuery>> {
|
||||
}
|
||||
|
||||
pub fn request_cursor_position(&mut self, out: &mut Outputter, q: CursorPositionQuery) {
|
||||
if !isatty(STDOUT_FILENO) {
|
||||
if !querying_allowed() {
|
||||
return;
|
||||
}
|
||||
let mut query = self.blocking_query();
|
||||
|
||||
Reference in New Issue
Block a user