Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ libc = { version = "0.2.153" }
libcst = { version = "1.8.4", default-features = false }
log = { version = "0.4.17" }
lsp-server = { version = "0.10.0" }
lsp-types = { package = "gen-lsp-types", version = "0.10.0", features = ["url"] }
lsp-types = { package = "gen-lsp-types", version = "0.11.0", features = ["url"] }
matchit = { version = "0.9.0" }
memchr = { version = "2.7.1" }
mimalloc = { version = "0.1.49", features = ["v2"] }
Expand Down
31 changes: 19 additions & 12 deletions crates/ruff_server/src/edit/notebook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,25 +63,32 @@ impl NotebookDocument {
let cells = self
.cells
.iter()
.map(|cell| match cell.kind {
NotebookCellKind::Code => ruff_notebook::Cell::Code(ruff_notebook::CodeCell {
execution_count: None,
id: None,
metadata: CellMetadata::default(),
outputs: vec![],
source: ruff_notebook::SourceValue::String(
cell.document.contents().to_string(),
),
}),
.filter_map(|cell| match cell.kind {
NotebookCellKind::Code => {
Some(ruff_notebook::Cell::Code(ruff_notebook::CodeCell {
execution_count: None,
id: None,
metadata: CellMetadata::default(),
outputs: vec![],
source: ruff_notebook::SourceValue::String(
cell.document.contents().to_string(),
),
}))
}
NotebookCellKind::Markup => {
ruff_notebook::Cell::Markdown(ruff_notebook::MarkdownCell {
Some(ruff_notebook::Cell::Markdown(ruff_notebook::MarkdownCell {
attachments: None,
id: None,
metadata: CellMetadata::default(),
source: ruff_notebook::SourceValue::String(
cell.document.contents().to_string(),
),
})
}))
}
NotebookCellKind::Custom(_) => {
// Ignore unsupported cell kinds. This arm should never be reached unless a
// client sends a value which is not mentioned/supported in the LSP.
None
}
})
.collect();
Expand Down
33 changes: 20 additions & 13 deletions crates/ty_server/src/document/notebook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl NotebookDocument {
let cells = self
.cells
.iter()
.map(|cell| {
.filter_map(|cell| {
let cell_text =
if let Ok(document) = index.document(&DocumentKey::from_uri(&cell.uri)) {
if let Some(text_document) = document.as_text() {
Expand All @@ -89,23 +89,30 @@ impl NotebookDocument {

let source = ruff_notebook::SourceValue::String(cell_text);
match cell.kind {
NotebookCellKind::Code => ruff_notebook::Cell::Code(ruff_notebook::CodeCell {
execution_count: cell
.execution_summary
.as_ref()
.map(|summary| i64::from(summary.execution_order)),
id: None,
metadata: CellMetadata::default(),
outputs: vec![],
source,
}),
NotebookCellKind::Code => {
Some(ruff_notebook::Cell::Code(ruff_notebook::CodeCell {
execution_count: cell
.execution_summary
.as_ref()
.map(|summary| i64::from(summary.execution_order)),
id: None,
metadata: CellMetadata::default(),
outputs: vec![],
source,
}))
}
NotebookCellKind::Markup => {
ruff_notebook::Cell::Markdown(ruff_notebook::MarkdownCell {
Some(ruff_notebook::Cell::Markdown(ruff_notebook::MarkdownCell {
attachments: None,
id: None,
metadata: CellMetadata::default(),
source,
})
}))
}
NotebookCellKind::Custom(_) => {
// Ignore unsupported cell kinds. This arm should never be reached unless a
// client sends a value which is not mentioned/supported in the LSP.
None
}
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ impl SyncNotificationHandler for DidChangeWatchedFiles {
path: system_path,
kind: DeletedKind::Any,
},
// Custom file change types are not supported and should be ignored.
FileChangeType::Custom(_) => continue,
};

changes.push(change_event);
Expand Down
2 changes: 1 addition & 1 deletion crates/ty_server/tests/e2e/workspace_folders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ fn condensed_full_document_diagnostic_report(report: FullDocumentDiagnosticRepor
Some(DiagnosticSeverity::Warning) => "WARNING",
Some(DiagnosticSeverity::Information) => "INFORMATION",
Some(DiagnosticSeverity::Hint) => "HINT",
None => "unknown",
Some(DiagnosticSeverity::Custom(_)) | None => "unknown",
};
let Message::String(message) = d.message else {
panic!(
Expand Down
Loading