mirror of
https://github.com/hexedtech/codemp.git
synced 2024-12-23 05:14:54 +01:00
fix: uuid was copy, string is not
This commit is contained in:
parent
917a6b96c2
commit
fb5bb51e65
5 changed files with 10 additions and 9 deletions
|
@ -92,10 +92,10 @@ pub extern "system" fn Java_mp_code_CursorController_send<'local>(
|
|||
let user = if user.is_null() {
|
||||
None
|
||||
} else {
|
||||
let user: String = env.get_string(&user)
|
||||
Some(env.get_string(&user)
|
||||
.map(|u| u.into())
|
||||
.jexcept(&mut env);
|
||||
Some(uuid::Uuid::parse_str(&user).jexcept(&mut env))
|
||||
.jexcept(&mut env)
|
||||
)
|
||||
};
|
||||
|
||||
let controller = unsafe { Box::leak(Box::from_raw(self_ptr as *mut crate::cursor::Controller)) };
|
||||
|
|
|
@ -35,7 +35,7 @@ impl BufferController {
|
|||
|
||||
#[napi(js_name = "get_path")]
|
||||
pub fn js_path(&self) -> napi::Result<&str> {
|
||||
Ok(&self.path())
|
||||
Ok(self.path())
|
||||
}
|
||||
|
||||
#[napi(js_name = "poll")]
|
||||
|
@ -50,7 +50,7 @@ impl BufferController {
|
|||
|
||||
#[napi(js_name = "recv")]
|
||||
pub async fn js_recv(&self) -> napi::Result<TextChange> {
|
||||
Ok(self.recv().await?.into())
|
||||
Ok(self.recv().await?)
|
||||
}
|
||||
|
||||
#[napi(js_name = "send")]
|
||||
|
|
|
@ -22,7 +22,7 @@ impl From<JsCursor> for crate::api::Cursor {
|
|||
start : (value.start_row, value.start_col),
|
||||
end: (value.end_row, value.end_col),
|
||||
buffer: value.buffer,
|
||||
user: value.user.map(|x| uuid::Uuid::parse_str(&x).expect("invalid uuid")),
|
||||
user: value.user,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ impl CursorController {
|
|||
#[napi(js_name= "try_recv")]
|
||||
pub async fn js_try_recv(&self) -> napi::Result<Option<JsCursor>> {
|
||||
Ok(self.try_recv().await?
|
||||
.map(|x| JsCursor::from(x)))
|
||||
.map(JsCursor::from))
|
||||
}
|
||||
|
||||
#[napi(js_name= "recv")]
|
||||
|
|
|
@ -52,6 +52,7 @@ fn tokio() -> &'static tokio::runtime::Runtime {
|
|||
}
|
||||
|
||||
// TODO cannot do Box<dyn IntoLuaMulti> ?? maybe its temporary because im using betas
|
||||
#[allow(unused)] // TODO pass callback args!
|
||||
enum CallbackArg {
|
||||
CursorController(CodempCursorController),
|
||||
BufferController(CodempBufferController),
|
||||
|
@ -351,7 +352,7 @@ impl LuaUserData for Cursor {
|
|||
}
|
||||
|
||||
fn add_fields<'lua, F: LuaUserDataFields<'lua, Self>>(fields: &mut F) {
|
||||
fields.add_field_method_get("user", |_, this| Ok(this.user.map(|x| x.to_string())));
|
||||
fields.add_field_method_get("user", |_, this| Ok(this.user.clone()));
|
||||
fields.add_field_method_get("buffer", |_, this| Ok(this.buffer.clone()));
|
||||
fields.add_field_method_get("start", |_, this| Ok(RowCol::from(this.start)));
|
||||
fields.add_field_method_get("finish", |_, this| Ok(RowCol::from(this.end)));
|
||||
|
|
|
@ -160,6 +160,6 @@ impl Cursor {
|
|||
|
||||
#[getter(user)]
|
||||
fn pyuser(&self) -> Option<String> {
|
||||
self.user.map(|user| user.to_string())
|
||||
self.user.clone()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue