mirror of https://github.com/helix-editor/helix
Merge 3bff12f995
into 205e7ece70
commit
e3cb245ef1
|
@ -707,6 +707,9 @@ impl Client {
|
||||||
]),
|
]),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}),
|
}),
|
||||||
|
/*experimental: Some(
|
||||||
|
serde_json::from_str("{\"colorDiagnosticOutput\": true}").unwrap(),
|
||||||
|
),*/
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
trace: None,
|
trace: None,
|
||||||
|
|
|
@ -29,7 +29,7 @@ use helix_view::{
|
||||||
use crate::{
|
use crate::{
|
||||||
compositor::{self, Compositor},
|
compositor::{self, Compositor},
|
||||||
job::Callback,
|
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};
|
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);
|
.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)
|
.truncate_start(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ use std::{
|
||||||
use crate::ui::{Prompt, PromptEvent};
|
use crate::ui::{Prompt, PromptEvent};
|
||||||
use helix_core::{
|
use helix_core::{
|
||||||
char_idx_at_visual_offset, fuzzy::MATCHER, movement::Direction,
|
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::{
|
use helix_view::{
|
||||||
editor::Action,
|
editor::Action,
|
||||||
|
@ -64,6 +64,7 @@ pub const MAX_FILE_SIZE_FOR_PREVIEW: u64 = 10 * 1024 * 1024;
|
||||||
pub enum PathOrId<'a> {
|
pub enum PathOrId<'a> {
|
||||||
Id(DocumentId),
|
Id(DocumentId),
|
||||||
Path(&'a Path),
|
Path(&'a Path),
|
||||||
|
Document(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> From<&'a Path> for PathOrId<'a> {
|
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)?;
|
let (path_or_id, range) = (self.file_fn.as_ref()?)(editor, current)?;
|
||||||
|
|
||||||
match path_or_id {
|
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) => {
|
PathOrId::Path(path) => {
|
||||||
if let Some(doc) = editor.document_by_path(path) {
|
if let Some(doc) = editor.document_by_path(path) {
|
||||||
return Some((Preview::EditorDocument(doc), range));
|
return Some((Preview::EditorDocument(doc), range));
|
||||||
|
|
Loading…
Reference in New Issue