Skip to content

Commit e46601b

Browse files
16bit-ykikoclaude
andcommitted
fix: data race in stateful worker and whole-document didChange parsing
Two fixes: 1. stateful_worker: move CompileParams copy after strand lock so concurrent Compile requests don't overwrite doc fields while et::queue work is reading them. DocumentUpdate only marks dirty instead of modifying doc.text to avoid data race with thread pool. 2. master_server: remove whole-document didChange workaround now that eventide correctly rejects variant candidates with missing required fields (clice-io/kotatsu#95). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 3760c71 commit e46601b

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

src/server/master_server.cpp

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1382,22 +1382,13 @@ void MasterServer::register_handlers() {
13821382
protocol::TextDocumentContentChangeWholeDocument>) {
13831383
doc.text = c.text;
13841384
} else {
1385+
// Incremental change: replace range
13851386
auto& range = c.range;
1386-
// Workaround: eventide variant deserialization always
1387-
// picks TextDocumentContentChangePartial (index 0).
1388-
// When the client sends a whole-document change (no range
1389-
// in JSON), the range defaults to {0,0}-{0,0}. Detect
1390-
// this and treat as a full replacement.
1391-
if(range.start.line == 0 && range.start.character == 0 &&
1392-
range.end.line == 0 && range.end.character == 0) {
1393-
doc.text = c.text;
1394-
} else {
1395-
lsp::PositionMapper mapper(doc.text, lsp::PositionEncoding::UTF16);
1396-
auto start = mapper.to_offset(range.start);
1397-
auto end = mapper.to_offset(range.end);
1398-
if(start && end && *start <= *end) {
1399-
doc.text.replace(*start, *end - *start, c.text);
1400-
}
1387+
lsp::PositionMapper mapper(doc.text, lsp::PositionEncoding::UTF16);
1388+
auto start = mapper.to_offset(range.start);
1389+
auto end = mapper.to_offset(range.end);
1390+
if(start && end && *start <= *end) {
1391+
doc.text.replace(*start, *end - *start, c.text);
14011392
}
14021393
}
14031394
},

0 commit comments

Comments
 (0)