mirror of
https://github.com/nushell/nushell.git
synced 2025-01-03 13:00:08 +01:00
adding span to value encoding
This commit is contained in:
parent
c56a233808
commit
1f4c34fa04
@ -187,7 +187,7 @@ impl Command for PluginDeclaration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Deserialize response from plugin to extract the resulting value
|
// Deserialize response from plugin to extract the resulting value
|
||||||
let signature = if let Some(stdout_reader) = child.stdout.take() {
|
let pipeline_data = if let Some(stdout_reader) = child.stdout.take() {
|
||||||
let mut buf_read = BufReader::with_capacity(OUTPUT_BUFFER_SIZE, stdout_reader);
|
let mut buf_read = BufReader::with_capacity(OUTPUT_BUFFER_SIZE, stdout_reader);
|
||||||
let response = plugin_call::decode_response(&mut buf_read)
|
let response = plugin_call::decode_response(&mut buf_read)
|
||||||
.map_err(|err| ShellError::PluginError(err.to_string()))?;
|
.map_err(|err| ShellError::PluginError(err.to_string()))?;
|
||||||
@ -208,7 +208,7 @@ impl Command for PluginDeclaration {
|
|||||||
|
|
||||||
match child.wait() {
|
match child.wait() {
|
||||||
Err(err) => Err(ShellError::PluginError(format!("{}", err))),
|
Err(err) => Err(ShellError::PluginError(format!("{}", err))),
|
||||||
Ok(_) => Ok(signature),
|
Ok(_) => Ok(pipeline_data),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,8 @@ use crate::plugin::PluginError;
|
|||||||
use crate::plugin_capnp::value;
|
use crate::plugin_capnp::value;
|
||||||
use nu_protocol::{Span, Value};
|
use nu_protocol::{Span, Value};
|
||||||
|
|
||||||
pub(crate) fn serialize_value(value: &Value, mut builder: value::Builder) -> Span {
|
pub(crate) fn serialize_value(value: &Value, mut builder: value::Builder) {
|
||||||
match value {
|
let value_span = match value {
|
||||||
Value::Nothing { span } => {
|
Value::Nothing { span } => {
|
||||||
builder.set_void(());
|
builder.set_void(());
|
||||||
*span
|
*span
|
||||||
@ -38,7 +38,11 @@ pub(crate) fn serialize_value(value: &Value, mut builder: value::Builder) -> Spa
|
|||||||
// we have to define the encoding for that object in this match
|
// we have to define the encoding for that object in this match
|
||||||
Span::unknown()
|
Span::unknown()
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
|
let mut span = builder.reborrow().init_span();
|
||||||
|
span.set_start(value_span.start as u64);
|
||||||
|
span.set_end(value_span.end as u64);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn deserialize_value(reader: value::Reader) -> Result<Value, PluginError> {
|
pub(crate) fn deserialize_value(reader: value::Reader) -> Result<Value, PluginError> {
|
||||||
@ -95,10 +99,7 @@ mod tests {
|
|||||||
|
|
||||||
let mut builder = message.init_root::<value::Builder>();
|
let mut builder = message.init_root::<value::Builder>();
|
||||||
|
|
||||||
let value_span = serialize_value(value, builder.reborrow());
|
serialize_value(value, builder.reborrow());
|
||||||
let mut span = builder.reborrow().init_span();
|
|
||||||
span.set_start(value_span.start as u64);
|
|
||||||
span.set_end(value_span.end as u64);
|
|
||||||
|
|
||||||
serialize_packed::write_message(writer, &message)
|
serialize_packed::write_message(writer, &message)
|
||||||
.map_err(|e| PluginError::EncodingError(e.to_string()))
|
.map_err(|e| PluginError::EncodingError(e.to_string()))
|
||||||
|
Loading…
Reference in New Issue
Block a user