Skip to content

Commit

Permalink
api: update ClearAutocmdsOpts for nightly
Browse files Browse the repository at this point in the history
  • Loading branch information
noib3 committed Oct 1, 2023
1 parent 2503fdb commit e2ae531
Showing 1 changed file with 34 additions and 2 deletions.
36 changes: 34 additions & 2 deletions crates/oxi-api/src/opts/clear_autocmds.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#[cfg(feature = "neovim-nightly")]
use oxi_types::BufHandle;
use oxi_types::{Array, Object};

use crate::Buffer;
Expand All @@ -19,9 +21,19 @@ pub struct ClearAutocmdsOpts {
#[derive(Clone, Debug, Default)]
#[repr(C)]
pub struct ClearAutocmdsOpts {
buffer: Object,
/// <pattern><buffer><group><event>1
mask: u64,

/// 3rd in the mask.
buffer: BufHandle,

/// 1st in the mask.
event: Object,

/// 2nd in the mask.
group: Object,

/// 4th in the mask.
pattern: Object,
}

Expand All @@ -41,7 +53,15 @@ impl ClearAutocmdsOptsBuilder {
/// used together with [`patterns`](ClearAutocmdsOptsBuilder::patterns).
#[inline]
pub fn buffer(&mut self, buffer: Buffer) -> &mut Self {
self.0.buffer = buffer.into();
#[cfg(not(feature = "neovim-nightly"))]
{
self.0.buffer = buffer.into();
}
#[cfg(feature = "neovim-nightly")]
{
self.0.buffer = buffer.0;
self.0.mask |= 0b01001;
}
self
}

Expand All @@ -53,6 +73,10 @@ impl ClearAutocmdsOptsBuilder {
I: IntoIterator<Item = &'a str>,
{
self.0.event = Array::from_iter(iter).into();
#[cfg(feature = "neovim-nightly")]
{
self.0.mask |= 0b00011;
}
self
}

Expand All @@ -66,6 +90,10 @@ impl ClearAutocmdsOptsBuilder {
I: IntoIterator<Item = &'a str>,
{
self.0.pattern = Array::from_iter(iter).into();
#[cfg(feature = "neovim-nightly")]
{
self.0.mask |= 0b10001;
}
self
}

Expand All @@ -77,6 +105,10 @@ impl ClearAutocmdsOptsBuilder {
Grp: StringOrInt,
{
self.0.group = group.to_object();
#[cfg(feature = "neovim-nightly")]
{
self.0.mask |= 0b00101;
}
self
}

Expand Down

0 comments on commit e2ae531

Please sign in to comment.