Revert "Fix ESLint linebreak-style errors by preserving line endings in LSP communication (#38773)" (#41355)

This reverts commit 435eab6896.

This caused format on save to scroll down to bottom instead of keeping
the position.

Release Notes:

- N/A
This commit is contained in:
Kirill Bulatov
2025-10-28 08:45:02 +00:00
committed by GitHub
parent bd0bcdb0ed
commit 1b6cde7032
7 changed files with 91 additions and 273 deletions
+8 -10
View File
@@ -2492,7 +2492,7 @@ impl LocalLspStore {
uri.clone(),
adapter.language_id(&language.name()),
0,
initial_snapshot.text_with_original_line_endings(),
initial_snapshot.text(),
);
vec![snapshot]
@@ -7574,7 +7574,6 @@ impl LspStore {
let previous_snapshot = buffer_snapshots.last()?;
let build_incremental_change = || {
let line_ending = next_snapshot.line_ending();
buffer
.edits_since::<Dimensions<PointUtf16, usize>>(
previous_snapshot.snapshot.version(),
@@ -7582,18 +7581,16 @@ impl LspStore {
.map(|edit| {
let edit_start = edit.new.start.0;
let edit_end = edit_start + (edit.old.end.0 - edit.old.start.0);
let new_text = next_snapshot
.text_for_range(edit.new.start.1..edit.new.end.1)
.collect();
lsp::TextDocumentContentChangeEvent {
range: Some(lsp::Range::new(
point_to_lsp(edit_start),
point_to_lsp(edit_end),
)),
range_length: None,
// Collect changed text and preserve line endings.
// text_for_range returns chunks with normalized \n, so we need to
// convert to the buffer's actual line ending for LSP.
text: line_ending.into_string(
next_snapshot.text_for_range(edit.new.start.1..edit.new.end.1),
),
text: new_text,
}
})
.collect()
@@ -7613,7 +7610,7 @@ impl LspStore {
vec![lsp::TextDocumentContentChangeEvent {
range: None,
range_length: None,
text: next_snapshot.text_with_original_line_endings(),
text: next_snapshot.text(),
}]
}
Some(lsp::TextDocumentSyncKind::INCREMENTAL) => build_incremental_change(),
@@ -10998,12 +10995,13 @@ impl LspStore {
let snapshot = versions.last().unwrap();
let version = snapshot.version;
let initial_snapshot = &snapshot.snapshot;
let uri = lsp::Uri::from_file_path(file.abs_path(cx)).unwrap();
language_server.register_buffer(
uri,
adapter.language_id(&language.name()),
version,
buffer_handle.read(cx).text_with_original_line_endings(),
initial_snapshot.text(),
);
buffer_paths_registered.push((buffer_id, file.abs_path(cx)));
local