Add an experimental, WIP diagnostics grouping panel (#14515)
Provide a current, broken state as an experimental way to browse diagnostics. The diagnostics are grouped by lines and reduced into a block that, in case of multiple diagnostics per line, could be toggled back and forth to show more diagnostics on the line. Use `grouped_diagnostics::Deploy` to show the panel. Issues remaining: * panic on warnings toggle due to incorrect excerpt manipulation * badly styled blocks * no key bindings to navigate between blocks and toggle them * overall odd usability gains for certain groups of people Due to all above, the thing is feature-gated and not exposed to regular people. Release Notes: - N/A
This commit is contained in:
parent
2c6cb4ec16
commit
d7a25c1696
13 changed files with 1647 additions and 95 deletions
|
@ -4,6 +4,7 @@ mod toolbar_controls;
|
|||
|
||||
#[cfg(test)]
|
||||
mod diagnostics_tests;
|
||||
mod grouped_diagnostics;
|
||||
|
||||
use anyhow::Result;
|
||||
use collections::{BTreeSet, HashSet};
|
||||
|
@ -14,6 +15,7 @@ use editor::{
|
|||
scroll::Autoscroll,
|
||||
Editor, EditorEvent, ExcerptId, ExcerptRange, MultiBuffer, ToOffset,
|
||||
};
|
||||
use feature_flags::FeatureFlagAppExt;
|
||||
use futures::{
|
||||
channel::mpsc::{self, UnboundedSender},
|
||||
StreamExt as _,
|
||||
|
@ -52,6 +54,9 @@ pub fn init(cx: &mut AppContext) {
|
|||
ProjectDiagnosticsSettings::register(cx);
|
||||
cx.observe_new_views(ProjectDiagnosticsEditor::register)
|
||||
.detach();
|
||||
if !cx.has_flag::<feature_flags::GroupedDiagnostics>() {
|
||||
grouped_diagnostics::init(cx);
|
||||
}
|
||||
}
|
||||
|
||||
struct ProjectDiagnosticsEditor {
|
||||
|
@ -466,7 +471,9 @@ impl ProjectDiagnosticsEditor {
|
|||
position: (excerpt_id, entry.range.start),
|
||||
height: diagnostic.message.matches('\n').count() as u8 + 1,
|
||||
style: BlockStyle::Fixed,
|
||||
render: diagnostic_block_renderer(diagnostic, true),
|
||||
render: diagnostic_block_renderer(
|
||||
diagnostic, None, true, true,
|
||||
),
|
||||
disposition: BlockDisposition::Below,
|
||||
});
|
||||
}
|
||||
|
@ -798,7 +805,7 @@ impl Item for ProjectDiagnosticsEditor {
|
|||
const DIAGNOSTIC_HEADER: &'static str = "diagnostic header";
|
||||
|
||||
fn diagnostic_header_renderer(diagnostic: Diagnostic) -> RenderBlock {
|
||||
let (message, code_ranges) = highlight_diagnostic_message(&diagnostic);
|
||||
let (message, code_ranges) = highlight_diagnostic_message(&diagnostic, None);
|
||||
let message: SharedString = message;
|
||||
Box::new(move |cx| {
|
||||
let highlight_style: HighlightStyle = cx.theme().colors().text_accent.into();
|
||||
|
|
|
@ -973,8 +973,8 @@ fn editor_blocks(
|
|||
blocks.extend(
|
||||
snapshot
|
||||
.blocks_in_range(DisplayRow(0)..snapshot.max_point().row())
|
||||
.enumerate()
|
||||
.filter_map(|(ix, (row, block))| {
|
||||
.filter_map(|(row, block)| {
|
||||
let transform_block_id = block.id();
|
||||
let name: SharedString = match block {
|
||||
TransformBlock::Custom(block) => {
|
||||
let mut element = block.render(&mut BlockContext {
|
||||
|
@ -984,7 +984,7 @@ fn editor_blocks(
|
|||
line_height: px(0.),
|
||||
em_width: px(0.),
|
||||
max_width: px(0.),
|
||||
block_id: ix,
|
||||
transform_block_id,
|
||||
editor_style: &editor::EditorStyle::default(),
|
||||
});
|
||||
let element = element.downcast_mut::<Stateful<Div>>().unwrap();
|
||||
|
|
1419
crates/diagnostics/src/grouped_diagnostics.rs
Normal file
1419
crates/diagnostics/src/grouped_diagnostics.rs
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue