aboutsummaryrefslogtreecommitdiffstats
path: root/zellij-server/src/plugins
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2023-08-24 13:36:24 +0200
committerGitHub <noreply@github.com>2023-08-24 13:36:24 +0200
commitbc628abc1266cdc0dbce4f19a89727527a3e39a8 (patch)
tree6a0fcac6ec35c71a237bca0128a57a5b40afb0e3 /zellij-server/src/plugins
parentdocs(changelog): permission system (diff)
downloadsl0ppij-bc628abc1266cdc0dbce4f19a89727527a3e39a8.tar.gz
sl0ppij-bc628abc1266cdc0dbce4f19a89727527a3e39a8.tar.xz
sl0ppij-bc628abc1266cdc0dbce4f19a89727527a3e39a8.zip
feat(sessions): add a session manager to switch between sessions, tabs and panes and create new ones (#2721)
* write/read session metadata to disk for all sessions * switch session client side * fix tests * various adjustments * fix full screen focus bug in tiled panes * fix tests * fix permission sorting issue * cleanups * add session manager * fix tests * various cleanups * style(fmt): rustfmt * clear screen before switching sessions * I hate you clippy * truncate controls line to width * version session cache * attempt to fix plugin tests * style(fmt): rustfmt * another attempt to fix the tests in the ci
Diffstat (limited to 'zellij-server/src/plugins')
-rw-r--r--zellij-server/src/plugins/unit/plugin_tests.rs67
-rw-r--r--zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__go_to_tab.snap4
-rw-r--r--zellij-server/src/plugins/wasm_bridge.rs1
-rw-r--r--zellij-server/src/plugins/zellij_exports.rs39
4 files changed, 105 insertions, 6 deletions
diff --git a/zellij-server/src/plugins/unit/plugin_tests.rs b/zellij-server/src/plugins/unit/plugin_tests.rs
index e995a07b..222b14c6 100644
--- a/zellij-server/src/plugins/unit/plugin_tests.rs
+++ b/zellij-server/src/plugins/unit/plugin_tests.rs
@@ -539,6 +539,7 @@ pub fn load_new_plugin_from_hd() {
client_id,
size,
));
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
@@ -609,6 +610,7 @@ pub fn plugin_workers() {
// we send a SystemClipboardFailure to trigger the custom handler in the fixture plugin that
// will send a message to the worker and in turn back to the plugin to be rendered, so we know
// that this cycle is working
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
@@ -682,6 +684,7 @@ pub fn plugin_workers_persist_state() {
// we do this a second time so that the worker will log the first message on its own state and
// then send us the "received 2 messages" indication we check for below, letting us know it
// managed to persist its own state and act upon it
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
@@ -820,6 +823,7 @@ pub fn switch_to_mode_plugin_command() {
client_id,
size,
));
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
@@ -887,6 +891,7 @@ pub fn switch_to_mode_plugin_command_permission_denied() {
client_id,
size,
));
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
@@ -954,6 +959,7 @@ pub fn new_tabs_with_layout_plugin_command() {
client_id,
size,
));
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
@@ -1035,6 +1041,7 @@ pub fn new_tab_plugin_command() {
client_id,
size,
));
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
@@ -1102,6 +1109,7 @@ pub fn go_to_next_tab_plugin_command() {
client_id,
size,
));
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
@@ -1168,6 +1176,7 @@ pub fn go_to_previous_tab_plugin_command() {
client_id,
size,
));
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
@@ -1234,6 +1243,7 @@ pub fn resize_focused_pane_plugin_command() {
client_id,
size,
));
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
@@ -1300,6 +1310,7 @@ pub fn resize_focused_pane_with_direction_plugin_command() {
client_id,
size,
));
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
@@ -1366,6 +1377,7 @@ pub fn focus_next_pane_plugin_command() {
client_id,
size,
));
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
@@ -1432,6 +1444,7 @@ pub fn focus_previous_pane_plugin_command() {
client_id,
size,
));
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
@@ -1498,6 +1511,7 @@ pub fn move_focus_plugin_command() {
client_id,
size,
));
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
@@ -1564,6 +1578,7 @@ pub fn move_focus_or_tab_plugin_command() {
client_id,
size,
));
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
@@ -1630,6 +1645,7 @@ pub fn edit_scrollback_plugin_command() {
client_id,
size,
));
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
@@ -1696,6 +1712,7 @@ pub fn write_plugin_command() {
client_id,
size,
));
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
@@ -1762,6 +1779,7 @@ pub fn write_chars_plugin_command() {
client_id,
size,
));
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
@@ -1828,6 +1846,7 @@ pub fn toggle_tab_plugin_command() {
client_id,
size,
));
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
@@ -1894,6 +1913,7 @@ pub fn move_pane_plugin_command() {
client_id,
size,
));
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
@@ -1960,6 +1980,7 @@ pub fn move_pane_with_direction_plugin_command() {
client_id,
size,
));
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
@@ -2027,7 +2048,7 @@ pub fn clear_screen_plugin_command() {
client_id,
size,
));
- std::thread::sleep(std::time::Duration::from_millis(100));
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
@@ -2095,6 +2116,7 @@ pub fn scroll_up_plugin_command() {
client_id,
size,
));
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
@@ -2161,6 +2183,7 @@ pub fn scroll_down_plugin_command() {
client_id,
size,
));
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
@@ -2227,6 +2250,7 @@ pub fn scroll_to_top_plugin_command() {
client_id,
size,
));
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
@@ -2293,6 +2317,7 @@ pub fn scroll_to_bottom_plugin_command() {
client_id,
size,
));
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
@@ -2359,6 +2384,7 @@ pub fn page_scroll_up_plugin_command() {
client_id,
size,
));
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
@@ -2425,6 +2451,7 @@ pub fn page_scroll_down_plugin_command() {
client_id,
size,
));
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
@@ -2491,6 +2518,7 @@ pub fn toggle_focus_fullscreen_plugin_command() {
client_id,
size,
));
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
@@ -2557,6 +2585,7 @@ pub fn toggle_pane_frames_plugin_command() {
client_id,
size,
));
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
@@ -2623,6 +2652,7 @@ pub fn toggle_pane_embed_or_eject_plugin_command() {
client_id,
size,
));
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
@@ -2689,6 +2719,7 @@ pub fn undo_rename_pane_plugin_command() {
client_id,
size,
));
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
@@ -2755,6 +2786,7 @@ pub fn close_focus_plugin_command() {
client_id,
size,
));
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
@@ -2821,6 +2853,7 @@ pub fn toggle_active_tab_sync_plugin_command() {
client_id,
size,
));
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
@@ -2887,6 +2920,7 @@ pub fn close_focused_tab_plugin_command() {
client_id,
size,
));
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
@@ -2953,6 +2987,7 @@ pub fn undo_rename_tab_plugin_command() {
client_id,
size,
));
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
@@ -3019,6 +3054,7 @@ pub fn previous_swap_layout_plugin_command() {
client_id,
size,
));
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
@@ -3085,6 +3121,7 @@ pub fn next_swap_layout_plugin_command() {
client_id,
size,
));
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
@@ -3151,6 +3188,7 @@ pub fn go_to_tab_name_plugin_command() {
client_id,
size,
));
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
@@ -3217,6 +3255,7 @@ pub fn focus_or_create_tab_plugin_command() {
client_id,
size,
));
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
@@ -3283,6 +3322,7 @@ pub fn go_to_tab() {
client_id,
size,
));
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
@@ -3349,6 +3389,7 @@ pub fn start_or_reload_plugin() {
client_id,
size,
));
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
@@ -3422,6 +3463,7 @@ pub fn quit_zellij_plugin_command() {
client_id,
size,
));
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
@@ -3495,6 +3537,7 @@ pub fn detach_plugin_command() {
client_id,
size,
));
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
@@ -3568,6 +3611,7 @@ pub fn open_file_floating_plugin_command() {
client_id,
size,
));
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
@@ -3641,6 +3685,7 @@ pub fn open_file_plugin_command() {
client_id,
size,
));
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
@@ -3715,6 +3760,7 @@ pub fn open_file_with_line_plugin_command() {
client_id,
size,
));
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
@@ -3788,6 +3834,7 @@ pub fn open_file_with_line_floating_plugin_command() {
client_id,
size,
));
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
@@ -3861,6 +3908,7 @@ pub fn open_terminal_plugin_command() {
client_id,
size,
));
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
@@ -3934,6 +3982,7 @@ pub fn open_terminal_floating_plugin_command() {
client_id,
size,
));
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
@@ -4007,6 +4056,7 @@ pub fn open_command_pane_plugin_command() {
client_id,
size,
));
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
@@ -4080,6 +4130,7 @@ pub fn open_command_pane_floating_plugin_command() {
client_id,
size,
));
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
@@ -4146,6 +4197,7 @@ pub fn switch_to_tab_plugin_command() {
client_id,
size,
));
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
@@ -4207,6 +4259,7 @@ pub fn hide_self_plugin_command() {
client_id,
size,
));
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
@@ -4268,6 +4321,7 @@ pub fn show_self_plugin_command() {
client_id,
size,
));
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
@@ -4334,6 +4388,7 @@ pub fn close_terminal_pane_plugin_command() {
client_id,
size,
));
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
@@ -4400,6 +4455,7 @@ pub fn close_plugin_pane_plugin_command() {
client_id,
size,
));
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
@@ -4466,6 +4522,7 @@ pub fn focus_terminal_pane_plugin_command() {
client_id,
size,
));
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
@@ -4532,6 +4589,7 @@ pub fn focus_plugin_pane_plugin_command() {
client_id,
size,
));
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
@@ -4598,6 +4656,7 @@ pub fn rename_terminal_pane_plugin_command() {
client_id,
size,
));
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
@@ -4664,6 +4723,7 @@ pub fn rename_plugin_pane_plugin_command() {
client_id,
size,
));
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
@@ -4730,6 +4790,7 @@ pub fn rename_tab_plugin_command() {
client_id,
size,
));
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
@@ -4805,6 +4866,7 @@ pub fn send_configuration_to_plugins() {
client_id,
size,
));
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
@@ -4868,6 +4930,7 @@ pub fn request_plugin_permissions() {
client_id,
size,
));
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
@@ -4955,6 +5018,7 @@ pub fn granted_permission_request_result() {
client_id,
size,
));
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
@@ -5040,6 +5104,7 @@ pub fn denied_permission_request_result() {
client_id,
size,
));
+ std::thread::sleep(std::time::Duration::from_millis(500));
let _ = plugin_thread_sender.send(PluginInstruction::Update(vec![(
None,
Some(client_id),
diff --git a/zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__go_to_tab.snap b/zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__go_to_tab.snap
index c3b12bd1..8e2a7570 100644
--- a/zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__go_to_tab.snap
+++ b/zellij-server/src/plugins/unit/snapshots/zellij_server__plugins__plugin_tests__go_to_tab.snap
@@ -1,11 +1,11 @@
---
source: zellij-server/src/plugins/./unit/plugin_tests.rs
-assertion_line: 2442
+assertion_line: 3306
expression: "format!(\"{:#?}\", new_tab_event)"
---
Some(
GoToTab(
- 2,
+ 3,
Some(
1,
),
diff --git a/zellij-server/src/plugins/wasm_bridge.rs b/zellij-server/src/plugins/wasm_bridge.rs
index 5c3c7c0d..fdc8f389 100644
--- a/zellij-server/src/plugins/wasm_bridge.rs
+++ b/zellij-server/src/plugins/wasm_bridge.rs
@@ -782,6 +782,7 @@ fn check_event_permission(
Event::ModeUpdate(..)
| Event::TabUpdate(..)
| Event::PaneUpdate(..)
+ | Event::SessionUpdate(..)
| Event::CopyToClipboard(..)
| Event::SystemClipboardFailure
| Event::InputReceived => PermissionType::ReadApplicationState,
diff --git a/zellij-server/src/plugins/zellij_exports.rs b/zellij-server/src/plugins/zellij_exports.rs
index f2effa19..16943dbb 100644
--- a/zellij-server/src/plugins/zellij_exports.rs
+++ b/zellij-server/src/plugins/zellij_exports.rs
@@ -2,6 +2,7 @@ use super::PluginInstruction;
use crate::plugins::plugin_map::{PluginEnv, Subscriptions};
use crate::plugins::wasm_bridge::handle_plugin_crash;
use crate::route::route_action;
+use crate::ServerInstruction;
use log::{debug, warn};
use serde::Serialize;
use std::{
@@ -15,7 +16,9 @@ use std::{
};
use wasmer::{imports, Function, ImportObject, Store, WasmerEnv};
use wasmer_wasi::WasiEnv;
-use zellij_utils::data::{CommandType, PermissionStatus, PermissionType, PluginPermission};
+use zellij_utils::data::{
+ CommandType, ConnectToSession, PermissionStatus, PermissionType, PluginPermission,
+};
use zellij_utils::input::permission::PermissionCache;
use url::Url;
@@ -205,6 +208,12 @@ fn host_run_plugin_command(env: &ForeignFunctionEnv) {
PluginCommand::RequestPluginPermissions(permissions) => {
request_permission(env, permissions)?
},
+ PluginCommand::SwitchSession(connect_to_session) => switch_session(
+ env,
+ connect_to_session.name,
+ connect_to_session.tab_position,
+ connect_to_session.pane_id,
+ )?,
},
(PermissionStatus::Denied, permission) => {
log::error!(
@@ -679,6 +688,31 @@ fn detach(env: &ForeignFunctionEnv) {
apply_action!(action, error_msg, env);
}
+fn switch_session(
+ env: &ForeignFunctionEnv,
+ session_name: Option<String>,
+ tab_position: Option<usize>,
+ pane_id: Option<(u32, bool)>,
+) -> Result<()> {
+ // pane_id is (id, is_plugin)
+ let err_context = || format!("Failed to switch session");
+ let client_id = env.plugin_env.client_id;
+ let tab_position = tab_position.map(|p| p + 1); // ¯\_()_/¯
+ let connect_to_session = ConnectToSession {
+ name: session_name,
+ tab_position,
+ pane_id,
+ };
+ env.plugin_env
+ .senders
+ .send_to_server(ServerInstruction::SwitchSession(
+ connect_to_session,
+ client_id,
+ ))
+ .with_context(err_context)?;
+ Ok(())
+}
+
fn edit_scrollback(env: &ForeignFunctionEnv) {
let action = Action::EditScrollback;
let error_msg = || format!("Failed to edit scrollback");
@@ -898,7 +932,7 @@ fn go_to_tab(env: &ForeignFunctionEnv, tab_index: u32) {
env.plugin_env.name()
)
};
- let action = Action::GoToTab(tab_index);
+ let action = Action::GoToTab(tab_index + 1);
apply_action!(action, error_msg, env);
}
@@ -1113,7 +1147,6 @@ fn check_command_permission(
_ => return (PermissionStatus::Granted, None),
};
- log::info!("plugin permissions: {:?}", plugin_env.permissions);
if let Some(permissions) = plugin_env.permissions.lock().unwrap().as_ref() {
if permissions.contains(&permission) {
return (PermissionStatus::Granted, None);