mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-12 13:24:19 +00:00
Fix context line handline in project diagnostic view
This commit is contained in:
parent
60f7169008
commit
04d577e326
6 changed files with 75 additions and 24 deletions
|
@ -16,6 +16,8 @@ use workspace::Workspace;
|
||||||
|
|
||||||
action!(Toggle);
|
action!(Toggle);
|
||||||
|
|
||||||
|
const CONTEXT_LINE_COUNT: u32 = 1;
|
||||||
|
|
||||||
pub fn init(cx: &mut MutableAppContext) {
|
pub fn init(cx: &mut MutableAppContext) {
|
||||||
cx.add_bindings([Binding::new("alt-shift-D", Toggle, None)]);
|
cx.add_bindings([Binding::new("alt-shift-D", Toggle, None)]);
|
||||||
cx.add_action(ProjectDiagnosticsEditor::toggle);
|
cx.add_action(ProjectDiagnosticsEditor::toggle);
|
||||||
|
@ -96,15 +98,18 @@ impl ProjectDiagnosticsEditor {
|
||||||
for (ix, entry) in group.entries.iter().map(Some).chain([None]).enumerate() {
|
for (ix, entry) in group.entries.iter().map(Some).chain([None]).enumerate() {
|
||||||
if let Some((range, start_ix)) = &mut pending_range {
|
if let Some((range, start_ix)) = &mut pending_range {
|
||||||
if let Some(entry) = entry {
|
if let Some(entry) = entry {
|
||||||
if entry.range.start.row <= range.end.row + 1 {
|
if entry.range.start.row <= range.end.row + 1 + CONTEXT_LINE_COUNT * 2 {
|
||||||
range.end = range.end.max(entry.range.end);
|
range.end = range.end.max(entry.range.end);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let excerpt_start = Point::new(range.start.row.saturating_sub(1), 0);
|
let excerpt_start =
|
||||||
let excerpt_end = snapshot
|
Point::new(range.start.row.saturating_sub(CONTEXT_LINE_COUNT), 0);
|
||||||
.clip_point(Point::new(range.end.row + 1, u32::MAX), Bias::Left);
|
let excerpt_end = snapshot.clip_point(
|
||||||
|
Point::new(range.end.row + CONTEXT_LINE_COUNT, u32::MAX),
|
||||||
|
Bias::Left,
|
||||||
|
);
|
||||||
let excerpt_id = excerpts.push_excerpt(
|
let excerpt_id = excerpts.push_excerpt(
|
||||||
ExcerptProperties {
|
ExcerptProperties {
|
||||||
buffer: &buffer,
|
buffer: &buffer,
|
||||||
|
@ -296,10 +301,8 @@ mod tests {
|
||||||
b(y);
|
b(y);
|
||||||
// comment 1
|
// comment 1
|
||||||
// comment 2
|
// comment 2
|
||||||
// comment 3
|
c(y);
|
||||||
// comment 4
|
d(x);
|
||||||
d(y);
|
|
||||||
e(x);
|
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
.unindent();
|
.unindent();
|
||||||
|
@ -310,6 +313,18 @@ mod tests {
|
||||||
.update_diagnostics(
|
.update_diagnostics(
|
||||||
None,
|
None,
|
||||||
vec![
|
vec![
|
||||||
|
DiagnosticEntry {
|
||||||
|
range: PointUtf16::new(1, 8)..PointUtf16::new(1, 9),
|
||||||
|
diagnostic: Diagnostic {
|
||||||
|
message:
|
||||||
|
"move occurs because `x` has type `Vec<char>`, which does not implement the `Copy` trait"
|
||||||
|
.to_string(),
|
||||||
|
severity: DiagnosticSeverity::INFORMATION,
|
||||||
|
is_primary: false,
|
||||||
|
group_id: 1,
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
},
|
||||||
DiagnosticEntry {
|
DiagnosticEntry {
|
||||||
range: PointUtf16::new(2, 8)..PointUtf16::new(2, 9),
|
range: PointUtf16::new(2, 8)..PointUtf16::new(2, 9),
|
||||||
diagnostic: Diagnostic {
|
diagnostic: Diagnostic {
|
||||||
|
@ -322,6 +337,16 @@ mod tests {
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
DiagnosticEntry {
|
||||||
|
range: PointUtf16::new(3, 6)..PointUtf16::new(3, 7),
|
||||||
|
diagnostic: Diagnostic {
|
||||||
|
message: "value moved here".to_string(),
|
||||||
|
severity: DiagnosticSeverity::INFORMATION,
|
||||||
|
is_primary: false,
|
||||||
|
group_id: 1,
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
},
|
||||||
DiagnosticEntry {
|
DiagnosticEntry {
|
||||||
range: PointUtf16::new(4, 6)..PointUtf16::new(4, 7),
|
range: PointUtf16::new(4, 6)..PointUtf16::new(4, 7),
|
||||||
diagnostic: Diagnostic {
|
diagnostic: Diagnostic {
|
||||||
|
@ -333,7 +358,7 @@ mod tests {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
DiagnosticEntry {
|
DiagnosticEntry {
|
||||||
range: PointUtf16::new(8, 6)..PointUtf16::new(8, 7),
|
range: PointUtf16::new(7, 6)..PointUtf16::new(7, 7),
|
||||||
diagnostic: Diagnostic {
|
diagnostic: Diagnostic {
|
||||||
message: "use of moved value\nvalue used here after move".to_string(),
|
message: "use of moved value\nvalue used here after move".to_string(),
|
||||||
severity: DiagnosticSeverity::ERROR,
|
severity: DiagnosticSeverity::ERROR,
|
||||||
|
@ -342,6 +367,16 @@ mod tests {
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
DiagnosticEntry {
|
||||||
|
range: PointUtf16::new(8, 6)..PointUtf16::new(8, 7),
|
||||||
|
diagnostic: Diagnostic {
|
||||||
|
message: "use of moved value\nvalue used here after move".to_string(),
|
||||||
|
severity: DiagnosticSeverity::ERROR,
|
||||||
|
is_primary: true,
|
||||||
|
group_id: 1,
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
},
|
||||||
],
|
],
|
||||||
cx,
|
cx,
|
||||||
)
|
)
|
||||||
|
@ -351,22 +386,40 @@ mod tests {
|
||||||
|
|
||||||
view.update(cx, |view, cx| {
|
view.update(cx, |view, cx| {
|
||||||
view.populate_excerpts(buffer, cx);
|
view.populate_excerpts(buffer, cx);
|
||||||
|
let editor = view.editor.update(cx, |editor, cx| editor.snapshot(cx));
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
view.editor.update(cx, |editor, cx| editor.display_text(cx)),
|
editor.text(),
|
||||||
concat!(
|
concat!(
|
||||||
"\n", // primary diagnostic message
|
// Diagnostic group 1 (error for `y`)
|
||||||
|
"\n", // primary message
|
||||||
"\n", // filename
|
"\n", // filename
|
||||||
" let x = vec![];\n",
|
" let x = vec![];\n",
|
||||||
" let y = vec![];\n",
|
" let y = vec![];\n",
|
||||||
" a(x);\n",
|
"\n", // supporting diagnostic
|
||||||
"\n", // context ellipsis
|
|
||||||
" a(x);\n",
|
" a(x);\n",
|
||||||
" b(y);\n",
|
" b(y);\n",
|
||||||
|
"\n", // supporting diagnostic
|
||||||
" // comment 1\n",
|
" // comment 1\n",
|
||||||
|
" // comment 2\n",
|
||||||
|
" c(y);\n",
|
||||||
|
"\n", // supporting diagnostic
|
||||||
|
" d(x);\n",
|
||||||
|
// Diagnostic group 2 (error for `x`)
|
||||||
|
"\n", // primary message
|
||||||
|
"\n", // filename
|
||||||
|
"fn main() {\n",
|
||||||
|
" let x = vec![];\n",
|
||||||
|
"\n", // supporting diagnostic
|
||||||
|
" let y = vec![];\n",
|
||||||
|
" a(x);\n",
|
||||||
|
"\n", // supporting diagnostic
|
||||||
|
" b(y);\n",
|
||||||
"\n", // context ellipsis
|
"\n", // context ellipsis
|
||||||
" // comment 3\n",
|
" c(y);\n",
|
||||||
" // comment 4\n",
|
" d(x);\n",
|
||||||
" d(y);"
|
"\n", // supporting diagnostic
|
||||||
|
"}"
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,4 +3,3 @@ fn main() {
|
||||||
println!("cargo:rustc-env=ZED_BUNDLE={}", bundled);
|
println!("cargo:rustc-env=ZED_BUNDLE={}", bundled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ use oauth2::{
|
||||||
TokenResponse as _, TokenUrl,
|
TokenResponse as _, TokenUrl,
|
||||||
};
|
};
|
||||||
use rand::thread_rng;
|
use rand::thread_rng;
|
||||||
|
use rpc::auth as zed_auth;
|
||||||
use scrypt::{
|
use scrypt::{
|
||||||
password_hash::{PasswordHash, PasswordHasher, PasswordVerifier, SaltString},
|
password_hash::{PasswordHash, PasswordHasher, PasswordVerifier, SaltString},
|
||||||
Scrypt,
|
Scrypt,
|
||||||
|
@ -19,7 +20,6 @@ use serde::{Deserialize, Serialize};
|
||||||
use std::{borrow::Cow, convert::TryFrom, sync::Arc};
|
use std::{borrow::Cow, convert::TryFrom, sync::Arc};
|
||||||
use surf::{StatusCode, Url};
|
use surf::{StatusCode, Url};
|
||||||
use tide::{log, Error, Server};
|
use tide::{log, Error, Server};
|
||||||
use rpc::auth as zed_auth;
|
|
||||||
|
|
||||||
static CURRENT_GITHUB_USER: &'static str = "current_github_user";
|
static CURRENT_GITHUB_USER: &'static str = "current_github_user";
|
||||||
static GITHUB_AUTH_URL: &'static str = "https://github.com/login/oauth/authorize";
|
static GITHUB_AUTH_URL: &'static str = "https://github.com/login/oauth/authorize";
|
||||||
|
|
|
@ -2,16 +2,15 @@ use crate::{
|
||||||
auth::RequestExt as _, github::Release, AppState, LayoutData, Request, RequestExt as _,
|
auth::RequestExt as _, github::Release, AppState, LayoutData, Request, RequestExt as _,
|
||||||
};
|
};
|
||||||
use comrak::ComrakOptions;
|
use comrak::ComrakOptions;
|
||||||
use serde::{Serialize};
|
use serde::Serialize;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use tide::{http::mime};
|
use tide::http::mime;
|
||||||
|
|
||||||
pub fn add_routes(releases: &mut tide::Server<Arc<AppState>>) {
|
pub fn add_routes(releases: &mut tide::Server<Arc<AppState>>) {
|
||||||
releases.at("/releases").get(get_releases);
|
releases.at("/releases").get(get_releases);
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn get_releases(mut request: Request) -> tide::Result {
|
async fn get_releases(mut request: Request) -> tide::Result {
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
struct ReleasesData {
|
struct ReleasesData {
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
|
@ -52,4 +51,4 @@ async fn get_releases(mut request: Request) -> tide::Result {
|
||||||
.body(request.state().render_template("releases.hbs", &data)?)
|
.body(request.state().render_template("releases.hbs", &data)?)
|
||||||
.content_type(mime::HTML)
|
.content_type(mime::HTML)
|
||||||
.build())
|
.build())
|
||||||
}
|
}
|
||||||
|
|
|
@ -561,7 +561,7 @@ fn test_random_concurrent_edits(mut rng: StdRng) {
|
||||||
match rng.gen_range(0..=100) {
|
match rng.gen_range(0..=100) {
|
||||||
0..=50 if mutation_count != 0 => {
|
0..=50 if mutation_count != 0 => {
|
||||||
let op = buffer.randomly_edit(&mut rng, 5).2;
|
let op = buffer.randomly_edit(&mut rng, 5).2;
|
||||||
network.broadcast(buffer.replica_id, vec!(op));
|
network.broadcast(buffer.replica_id, vec![op]);
|
||||||
log::info!("buffer {} text: {:?}", buffer.replica_id, buffer.text());
|
log::info!("buffer {} text: {:?}", buffer.replica_id, buffer.text());
|
||||||
mutation_count -= 1;
|
mutation_count -= 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ use parking_lot::Mutex;
|
||||||
use postage::watch;
|
use postage::watch;
|
||||||
use std::{cmp, sync::Arc};
|
use std::{cmp, sync::Arc};
|
||||||
use theme::ThemeRegistry;
|
use theme::ThemeRegistry;
|
||||||
use workspace::{Settings, Workspace, AppState};
|
use workspace::{AppState, Settings, Workspace};
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct ThemeSelectorParams {
|
pub struct ThemeSelectorParams {
|
||||||
|
|
Loading…
Reference in a new issue