Skip to content

Commit

Permalink
Add --keep flag
Browse files Browse the repository at this point in the history
- This commit will keep our Rust implementation and that of official
  Ruby implementation in sync.
  • Loading branch information
spamwax committed Sep 4, 2023
1 parent 5353a34 commit 383b0b1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ fn main() -> Result<(), String> {
let buffers = file_handler::get_requested_buffers(&settings)?;
// Send the files to remote editor
// let buffers = remote_editor::open_file_in_remote(&socket, buffers)?;
remote_editor::open_file_in_remote(&socket, &buffers)?;
remote_editor::open_file_in_remote(&socket, &buffers, &settings)?;

// If needed, fork so we yield the control back to terminal
if !settings.wait && run_fork()? {
Expand Down
4 changes: 3 additions & 1 deletion src/remote_editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ pub(crate) fn close_buffer(
pub(crate) fn open_file_in_remote(
socket: &socket2::Socket,
buffers: &HashMap<String, settings::OpenedBuffer>,
settings: &settings::Settings,
) -> Result<(), String> {
// ) -> Result<HashMap<String, settings::OpenedBuffer>, String> {
let bsize = socket.recv_buffer_size().map_err(|e| e.to_string())?;
Expand All @@ -77,13 +78,14 @@ pub(crate) fn open_file_in_remote(
"open\ndisplay-name: {}\n",
"real-path: {}\n",
"selection: {}\n",
"data-on-save: yes\nre-activate: yes\n",
"data-on-save: yes\nre-activate: {}\n",
"token: {}\n",
),
// host_name.to_string_lossy(),
opened_buffer.display_name.to_string_lossy(),
opened_buffer.canon_path.to_string_lossy(),
opened_buffer.line,
if settings.keep { "yes" } else { "no" },
token
);
trace!("header: {}", header);
Expand Down
4 changes: 4 additions & 0 deletions src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ pub(crate) struct Settings {
#[structopt(short, long, env = "RMATE_PORT", min_values = 1)]
pub port: Option<u16>,

/// Have TextMate retain window focus after file is closed
#[structopt(short, long)]
pub keep: bool,

/// Wait for file to be closed by TextMate/Sublime Text
#[structopt(short, long)]
pub wait: bool,
Expand Down

0 comments on commit 383b0b1

Please sign in to comment.