editor: Fix adding extraneous closing tags within TSX (#38534)

This commit is contained in:
Smit Barmase
2025-09-20 04:40:22 +05:30
committed by GitHub
parent 8df616e28b
commit be77682a3f
13 changed files with 218 additions and 84 deletions
+7 -4
View File
@@ -16,8 +16,8 @@ use collections::{HashMap, HashSet};
use futures::future;
use gpui::{App, AsyncApp, Entity, Task};
use language::{
Anchor, Bias, Buffer, BufferSnapshot, CachedLspAdapter, CharKind, OffsetRangeExt, PointUtf16,
ToOffset, ToPointUtf16, Transaction, Unclipped,
Anchor, Bias, Buffer, BufferSnapshot, CachedLspAdapter, CharKind, CharScopeContext,
OffsetRangeExt, PointUtf16, ToOffset, ToPointUtf16, Transaction, Unclipped,
language_settings::{InlayHintKind, LanguageSettings, language_settings},
point_from_lsp, point_to_lsp,
proto::{deserialize_anchor, deserialize_version, serialize_anchor, serialize_version},
@@ -350,7 +350,7 @@ impl LspCommand for PrepareRename {
}
Some(lsp::PrepareRenameResponse::DefaultBehavior { .. }) => {
let snapshot = buffer.snapshot();
let (range, _) = snapshot.surrounding_word(self.position, false);
let (range, _) = snapshot.surrounding_word(self.position, None);
let range = snapshot.anchor_after(range.start)..snapshot.anchor_before(range.end);
Ok(PrepareRenameResponse::Success(range))
}
@@ -2293,7 +2293,10 @@ impl LspCommand for GetCompletions {
range_for_token
.get_or_insert_with(|| {
let offset = self.position.to_offset(&snapshot);
let (range, kind) = snapshot.surrounding_word(offset, true);
let (range, kind) = snapshot.surrounding_word(
offset,
Some(CharScopeContext::Completion),
);
let range = if kind == Some(CharKind::Word) {
range
} else {