vim table containing emoji (#122)

This commit is contained in:
Clément DOUIN 2021-04-24 23:31:26 +02:00
parent 2d299e1d42
commit 17df485e19
No known key found for this signature in database
GPG key ID: 69C9B9CFFDEE2DEF
3 changed files with 25 additions and 4 deletions

View file

@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Improve config compatibility on Windows [#111](https://github.com/soywod/himalaya/pull/111)
- Vim table containing emoji [#122]
## [0.2.6] - 2021-04-17
@ -198,5 +199,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[#89]: https://github.com/soywod/himalaya/issues/89
[#96]: https://github.com/soywod/himalaya/issues/96
[#100]: https://github.com/soywod/himalaya/issues/100
[#122]: https://github.com/soywod/himalaya/issues/122
[#125]: https://github.com/soywod/himalaya/issues/125
[#126]: https://github.com/soywod/himalaya/issues/126

View file

@ -9,6 +9,7 @@ use serde::{
};
use std::{borrow::Cow, fmt, fs, path::PathBuf, result};
use tree_magic;
use unicode_width::UnicodeWidthStr;
use uuid::Uuid;
use crate::{
@ -196,19 +197,37 @@ impl<'a> ReadableMsg {
// Message
#[derive(Debug, Serialize)]
#[derive(Debug)]
pub struct Msg<'m> {
pub uid: u32,
pub flags: Flags<'m>,
pub subject: String,
pub sender: String,
pub date: String,
#[serde(skip_serializing)]
pub attachments: Vec<String>,
#[serde(skip_serializing)]
pub raw: Vec<u8>,
}
impl<'a> Serialize for Msg<'a> {
fn serialize<T>(&self, serializer: T) -> result::Result<T::Ok, T::Error>
where
T: ser::Serializer,
{
let mut state = serializer.serialize_struct("Msg", 7)?;
state.serialize_field("uid", &self.uid)?;
state.serialize_field("flags", &self.flags)?;
state.serialize_field("subject", &self.subject)?;
state.serialize_field(
"subject_len",
&UnicodeWidthStr::width(self.subject.as_str()),
)?;
state.serialize_field("sender", &self.sender)?;
state.serialize_field("sender_len", &UnicodeWidthStr::width(self.sender.as_str()))?;
state.serialize_field("date", &self.date)?;
state.end()
}
}
impl<'m> From<Vec<u8>> for Msg<'m> {
fn from(raw: Vec<u8>) -> Self {
Self {

View file

@ -229,7 +229,7 @@ function! s:get_max_widths(msgs, columns)
let max_widths = map(copy(a:columns), "strlen(s:config.labels[v:val])")
for msg in a:msgs
let widths = map(copy(a:columns), "strlen(msg[v:val])")
let widths = map(copy(a:columns), "has_key(msg, v:val . '_len') ? msg[v:val . '_len'] : strlen(msg[v:val])")
call map(max_widths, "max([widths[v:key], v:val])")
endfor