mirror of
https://github.com/hexedtech/codemp-intellij.git
synced 2024-11-24 16:04:48 +01:00
chore: bump to lib 0.5.1
This commit is contained in:
parent
154e8c26b5
commit
ca7da92b59
3 changed files with 17 additions and 39 deletions
|
@ -4,12 +4,11 @@ version = "0.1.0"
|
|||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
codemp = { git = "ssh://git@github.com/codewithotherpeopleandchangenamelater/codemp.git", tag = "v0.5.0", features = ["global", "sync"] }
|
||||
codemp = { git = "ssh://git@github.com/codewithotherpeopleandchangenamelater/codemp.git", tag = "v0.5.1", features = ["global", "sync"] }
|
||||
jni = { version = "0.21.1", features = ["invocation"] }
|
||||
jni-sys = "0.3.0"
|
||||
log = "0.4.20"
|
||||
rifgen = { git = "https://github.com/Kofituo/rifgen.git", rev = "d27d9785b2febcf5527f1deb6a846be5d583f7d7"}
|
||||
tokio = "1.34.0"
|
||||
|
||||
[build-dependencies]
|
||||
flapigen = "0.6.0"
|
||||
|
|
|
@ -59,18 +59,16 @@ public class BufferEventAwaiterTask extends Task.Backgroundable implements Dispo
|
|||
StringVec buffers = new StringVec(); //jni moment
|
||||
CodeMP.ACTIVE_BUFFERS.keySet().forEach(buffers::push);
|
||||
|
||||
Optional<String> bufferOptional = CodeMPHandler.selectBuffer(buffers, 100L);
|
||||
Optional<BufferHandler> bufferOptional = CodeMPHandler.selectBuffer(buffers, 100L);
|
||||
if(bufferOptional.isEmpty())
|
||||
continue;
|
||||
String buffer = bufferOptional.get();
|
||||
|
||||
BufferHandler handler = CodeMPHandler.getBuffer(buffer);
|
||||
BufferHandler buffer = bufferOptional.get();
|
||||
|
||||
List<TextChangeWrapper> changeList = new ArrayList<>();
|
||||
while(true) {
|
||||
Optional<TextChangeWrapper> changeOptional;
|
||||
try {
|
||||
changeOptional = handler.tryRecv();
|
||||
changeOptional = buffer.tryRecv();
|
||||
} catch(DeadlockedException e) {
|
||||
CodeMP.LOGGER.error(e.getMessage());
|
||||
continue;
|
||||
|
@ -83,7 +81,7 @@ public class BufferEventAwaiterTask extends Task.Backgroundable implements Dispo
|
|||
changeList.add(change);
|
||||
}
|
||||
|
||||
Editor bufferEditor = CodeMP.ACTIVE_BUFFERS.get(buffer);
|
||||
Editor bufferEditor = CodeMP.ACTIVE_BUFFERS.get(buffer.getName());
|
||||
ApplicationManager.getApplication().invokeLaterOnWriteThread(() ->
|
||||
ApplicationManager.getApplication().runWriteAction(() ->
|
||||
CommandProcessor.getInstance().executeCommand(
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
use codemp::prelude::*;
|
||||
use codemp::tools;
|
||||
use rifgen::rifgen_attr::{generate_access_methods, generate_interface, generate_interface_doc};
|
||||
|
||||
pub mod glue { //rifgen generated code
|
||||
|
@ -67,7 +68,7 @@ impl CodeMPHandler {
|
|||
}
|
||||
|
||||
#[generate_interface]
|
||||
fn select_buffer(mut buffer_ids: StringVec, timeout: i64) -> CodempResult<Option<String>> {
|
||||
fn select_buffer(mut buffer_ids: StringVec, timeout: i64) -> CodempResult<Option<BufferHandler>> {
|
||||
let mut buffers = Vec::new();
|
||||
for id in buffer_ids.v.iter_mut() {
|
||||
match CODEMP_INSTANCE.get_buffer(id.as_str()) {
|
||||
|
@ -76,35 +77,15 @@ impl CodeMPHandler {
|
|||
}
|
||||
}
|
||||
|
||||
let (tx, mut rx) = tokio::sync::mpsc::unbounded_channel();
|
||||
let mut tasks = Vec::new();
|
||||
for buffer in buffers {
|
||||
let _tx = tx.clone();
|
||||
let _buffer = buffer.clone();
|
||||
tasks.push(CODEMP_INSTANCE.rt().spawn(async move {
|
||||
match _buffer.poll().await {
|
||||
Ok(()) => _tx.send(Ok(Some(_buffer.name.clone()))),
|
||||
Err(_) => _tx.send(Err(CodempError::Channel { send: true })),
|
||||
}
|
||||
}))
|
||||
}
|
||||
let _tx = tx.clone();
|
||||
tasks.push(CODEMP_INSTANCE.rt().spawn(async move {
|
||||
tokio::time::sleep(Duration::from_millis(timeout as u64)).await;
|
||||
_tx.send(Ok(None))
|
||||
}));
|
||||
loop {
|
||||
match CODEMP_INSTANCE.rt().block_on(rx.recv()) {
|
||||
None => return Err(CodempError::Channel { send: false }),
|
||||
Some(Err(_)) => continue,
|
||||
Some(Ok(None)) => return Ok(None),
|
||||
Some(Ok(Some(x))) => {
|
||||
for t in tasks {
|
||||
t.abort();
|
||||
}
|
||||
return Ok(Some(x.clone()));
|
||||
},
|
||||
}
|
||||
let result = CODEMP_INSTANCE.rt().block_on(tools::select_buffer(
|
||||
buffers.as_slice(),
|
||||
Some(Duration::from_millis(timeout as u64))
|
||||
));
|
||||
|
||||
match result {
|
||||
Err(e) => Err(e),
|
||||
Ok(buffer) =>
|
||||
Ok(buffer.map(|buffer| BufferHandler { buffer }))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -180,7 +161,7 @@ impl BufferHandler {
|
|||
|
||||
#[generate_interface]
|
||||
fn get_name(&self) -> String {
|
||||
self.buffer.name.clone()
|
||||
self.buffer.name().to_string()
|
||||
}
|
||||
|
||||
#[generate_interface]
|
||||
|
|
Loading…
Reference in a new issue