Files
ruff/crates/ruff_server/tests/document.rs
Riley Bruins 612f2f2850 Switch to gen-lsp-types crate to provide LSP types (#24894)
## Summary

[gen-lsp-types](https://github.com/ribru17/gen-lsp-types) is an
alternative to the lsp-types crate, with types generated via codegen
from the official LSP Metamodel for correctness and completeness.

lsp-types issues fixed in gen-lsp-types:

- https://github.com/gluon-lang/lsp-types/issues/310
- https://github.com/gluon-lang/lsp-types/issues/308
- https://github.com/gluon-lang/lsp-types/issues/284
- https://github.com/gluon-lang/lsp-types/issues/278
- https://github.com/gluon-lang/lsp-types/issues/277
- https://github.com/gluon-lang/lsp-types/issues/260
- https://github.com/gluon-lang/lsp-types/issues/245
- https://github.com/gluon-lang/lsp-types/issues/93

## Test Plan

All affected test fixtures updated. Most (all?) are just field
reordering, struct type name renaming
2026-06-08 21:51:32 +05:30

101 lines
3.2 KiB
Rust

const PANDAS_HTML_SRC: &str = include_str!("../resources/test/fixtures/pandas_html.py");
use lsp_types::{
Position, Range, TextDocumentContentChangeEvent, TextDocumentContentChangePartial,
};
use ruff_server::{PositionEncoding, TextDocument};
#[test]
fn delete_lines_pandas_html() {
let mut document = TextDocument::new(PANDAS_HTML_SRC.to_string(), 1);
let changes = vec![
TextDocumentContentChangeEvent::TextDocumentContentChangePartial(
TextDocumentContentChangePartial {
range: Range {
start: Position {
line: 79,
character: 0,
},
end: Position {
line: 91,
character: 67,
},
},
text: String::new(),
..Default::default()
},
),
TextDocumentContentChangeEvent::TextDocumentContentChangePartial(
TextDocumentContentChangePartial {
range: Range {
start: Position {
line: 81,
character: 4,
},
end: Position {
line: 81,
character: 36,
},
},
text: "p".into(),
..Default::default()
},
),
TextDocumentContentChangeEvent::TextDocumentContentChangePartial(
TextDocumentContentChangePartial {
range: Range {
start: Position {
line: 81,
character: 5,
},
end: Position {
line: 81,
character: 5,
},
},
text: "a".into(),
..Default::default()
},
),
TextDocumentContentChangeEvent::TextDocumentContentChangePartial(
TextDocumentContentChangePartial {
range: Range {
start: Position {
line: 81,
character: 6,
},
end: Position {
line: 81,
character: 6,
},
},
text: "s".into(),
..Default::default()
},
),
TextDocumentContentChangeEvent::TextDocumentContentChangePartial(
TextDocumentContentChangePartial {
range: Range {
start: Position {
line: 81,
character: 7,
},
end: Position {
line: 81,
character: 7,
},
},
text: "s".into(),
..Default::default()
},
),
];
for (version, change) in (2..).zip(changes) {
document.apply_changes(vec![change], version, PositionEncoding::UTF16);
}
insta::assert_snapshot!(document.contents());
}