Change:
This was filed at , but I believe the crash is a VS Code issue. I can reproduce the issue by doing the following: Set up a Dart SDK and install the Dart extension Open an empty folder and create a file with the following contents (and no trailing newline): Run the "Organize Imports" command VS Code immediately hangs and the cursor stops flashing, eventually reporting the crash and asking to reopen/close I ran the Dart language server from source and stripped out a lot of the capabilities to reduce the traffic. When removing the Semantic Tokens capability, the issue stops occurring, so it may be related to semantic tokens but I'm not certain. Here is the LSP log (the version running the reduced set of Dart server capabilities): Here is the crash-dump folder: Symbolicated: , though (mentioned at ) is a 404 so these may be incomplete. I've not had any luck reproducing this without the Dart extension/server by writing extension code that just applies the same edits (possibly because it requires semantic tokens) nor have I spotted anything unusual in the LSP traffic, but I'll have another go through these and post back if I figure anything out. Hopefully the crash log will help though. VS Code version:
I was able to reproduce this in an isolated test extension by just hard-coding semantic tokens and the edits: The complete code looks like this (though you'll need to contribute the "danny" language or change it.. I didn't want to reuse an existing language incase it had its own semantic tokens):
Doesn't seem to reproduce in the . However, I can observe in VS Code that LineTokens is created with unsorted offsets:
Thank you for the clean repro!
Fix LGTM, thanks! /verified

Discussion:
// 3a, 3b, 3c if (tokenDeltaLine === endDeltaLine && tokenEndCharacter > endCharacter) { // 3c. The token starts inside the deletion range, and ends after the deletion range <del> // => the token moves left and shrinks if (tokenDeltaLine === startDeltaLine) { // the deletion started on the same line as the token // => the token moves left and shrinks tokenStartCharacter = startCharacter; tokenEndCharacter = tokenStartCharacter + (tokenEndCharacter - endCharacter); } else { // the deletion started on a line above the token // => the token moves to the beginning of the line tokenStartCharacter = 0; tokenEndCharacter = tokenStartCharacter + (tokenEndCharacter - endCharacter); } </del> <ins> // => the token moves to continue right after the deletion tokenDeltaLine = startDeltaLine; tokenStartCharacter = startCharacter; tokenEndCharacter = tokenStartCharacter + (tokenEndCharacter - endCharacter); </ins> } else { // 3a. The token is inside the deletion range // 3b. The token starts inside the deletion range, and ends at the same position as the deletion range

return result; } <del> // function extractState </del> function testTokensAdjustment(rawInitialState: string[], edits: ISingleEditOperation[], rawFinalState: string[]) { const initialState = parseTokensState(rawInitialState); const model = createTextModel(initialState.text);

); }); <ins> test('issue #179268: a complex edit', () => { testTokensAdjustment( [ `|export| |'interior_material_selector.dart'|;`, `|export| |'mileage_selector.dart'|;`, `|export| |'owners_selector.dart'|;`, `|export| |'price_selector.dart'|;`, `|export| |'seat_count_selector.dart'|;`, `|export| |'year_selector.dart'|;`, `|export| |'winter_options_selector.dart'|;|export| |'camera_selector.dart'|;` ], [ { range: new Range(1, 9, 1, 9), text: `camera_selector.dart';nexport '` }, { range: new Range(6, 9, 7, 9), text: `` }, { range: new Range(7, 39, 7, 39), text: `n` }, { range: new Range(7, 47, 7, 48), text: `ye` }, { range: new Range(7, 49, 7, 51), text: `` }, { range: new Range(7, 52, 7, 53), text: `` }, ], [ `|export| |'|camera_selector.dart';`, `export 'interior_material_selector.dart';`, `|export| |'mileage_selector.dart'|;`, `|export| |'owners_selector.dart'|;`, `|export| |'price_selector.dart'|;`, `|export| |'seat_count_selector.dart'|;`, `|export| |'||winter_options_selector.dart'|;`, `|export| |'year_selector.dart'|;` ] ); }); </ins> test('issue #91936: Semantic token color highlighting fails on line with selected text', () => { const model = createTextModel('                    else if ($s = 08) then 'b''); model.tokenization.setSemanticTokens([