mirror of https://github.com/helix-editor/helix
Merge 3bff12f995
into 205e7ece70
commit
e3cb245ef1
|
@ -707,6 +707,9 @@ impl Client {
|
|||
]),
|
||||
..Default::default()
|
||||
}),
|
||||
/*experimental: Some(
|
||||
serde_json::from_str("{\"colorDiagnosticOutput\": true}").unwrap(),
|
||||
),*/
|
||||
..Default::default()
|
||||
},
|
||||
trace: None,
|
||||
|
|
|
@ -29,7 +29,7 @@ use helix_view::{
|
|||
use crate::{
|
||||
compositor::{self, Compositor},
|
||||
job::Callback,
|
||||
ui::{self, overlay::overlaid, FileLocation, Picker, Popup, PromptEvent},
|
||||
ui::{self, overlay::overlaid, picker::PathOrId, FileLocation, Picker, Popup, PromptEvent},
|
||||
};
|
||||
|
||||
use std::{cmp::Ordering, collections::HashSet, fmt::Display, future::Future, path::Path};
|
||||
|
@ -295,7 +295,20 @@ fn diag_picker(
|
|||
.immediately_show_diagnostic(doc, view.id);
|
||||
},
|
||||
)
|
||||
.with_preview(move |_editor, diag| location_to_file_location(&diag.location))
|
||||
.with_preview(move |_editor, diag| match diag.diag.data {
|
||||
Some(ref data) => {
|
||||
if let Some(error_string) = data
|
||||
.as_object()
|
||||
.and_then(|object| object.get("rendered"))
|
||||
.and_then(|rendered| rendered.as_str())
|
||||
{
|
||||
Some((PathOrId::Document(error_string.to_string()), Some((0, 0))))
|
||||
} else {
|
||||
location_to_file_location(&diag.location)
|
||||
}
|
||||
}
|
||||
None => location_to_file_location(&diag.location),
|
||||
})
|
||||
.truncate_start(false)
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ use std::{
|
|||
use crate::ui::{Prompt, PromptEvent};
|
||||
use helix_core::{
|
||||
char_idx_at_visual_offset, fuzzy::MATCHER, movement::Direction,
|
||||
text_annotations::TextAnnotations, unicode::segmentation::UnicodeSegmentation, Position,
|
||||
text_annotations::TextAnnotations, unicode::segmentation::UnicodeSegmentation, Position, Rope,
|
||||
};
|
||||
use helix_view::{
|
||||
editor::Action,
|
||||
|
@ -64,6 +64,7 @@ pub const MAX_FILE_SIZE_FOR_PREVIEW: u64 = 10 * 1024 * 1024;
|
|||
pub enum PathOrId<'a> {
|
||||
Id(DocumentId),
|
||||
Path(&'a Path),
|
||||
Document(String),
|
||||
}
|
||||
|
||||
impl<'a> From<&'a Path> for PathOrId<'a> {
|
||||
|
@ -575,6 +576,21 @@ impl<T: 'static + Send + Sync, D: 'static + Send + Sync> Picker<T, D> {
|
|||
let (path_or_id, range) = (self.file_fn.as_ref()?)(editor, current)?;
|
||||
|
||||
match path_or_id {
|
||||
PathOrId::Document(s) => {
|
||||
let rope = Rope::from_str(&s);
|
||||
let document =
|
||||
Document::from(rope, None, editor.config.clone(), editor.syn_loader.clone());
|
||||
let _ = self.preview_cache.insert(
|
||||
Path::new("/tmp/.helix_error").into(),
|
||||
CachedPreview::Document(Box::new(document)),
|
||||
);
|
||||
let preview = Preview::Cached(
|
||||
self.preview_cache
|
||||
.get(Path::new("/tmp/.helix_error"))
|
||||
.unwrap(),
|
||||
);
|
||||
Some((preview, range))
|
||||
}
|
||||
PathOrId::Path(path) => {
|
||||
if let Some(doc) = editor.document_by_path(path) {
|
||||
return Some((Preview::EditorDocument(doc), range));
|
||||
|
|
Loading…
Reference in New Issue