Skip to content

The adjacent span is ignored in fixer #4204

@mysteryven

Description

@mysteryven
test('extension is not outdated when there is no local and gallery', () => {
    const extension = instantiationService.createInstance(Extension, () => ExtensionState.Installed, () => undefined, undefined, undefined, undefined, undefined);
    assert.strictEqual(extension.outdated, false);
});

microsoft/vscode@c37f4a4/src/vs/workbench/contrib/extensions/test/electron-sandbox/extension.test.ts#L29-L32

Our fixer needs to run twice to fix this, tested on unicorn/no-useless-undefined, it needs once.


Why our fixer need to run twice

            if i64::from(start) <= last_pos {
                return;
            }

https://github.com/oxc-project/oxc/blob/main/crates/oxc_linter/src/fixer.rs#L278

I found that span is an interval that is closed on the left and open on the right. It should not be <=, which will cause the continuous interval to be skipped. It should be <.

The test case has to be modified to allow continuous interval modification, but I found that it will cause no_useless_escape test failure

https://github.com/oxc-project/oxc/blob/main/crates/oxc_linter/src/fixer.rs#L520

    const REMOVE_START: Fix = Fix::delete(Span::new(0, 4));
    const REPLACE_ID: Fix = Fix { span: Span::new(4, 10), content: Cow::Borrowed("foo") };
    fn apply_two_fix_when_the_start_the_same_as_the_previous_end() {
        let result = get_fix_result(vec![
            create_message(remove_start(), Some(REMOVE_START)),
            create_message(replace_id(), Some(REPLACE_ID)),
        ]);
        assert_eq!(result.fixed_code, TEST_CODE.replace("var answer", "foo"));
        assert!(result.fixed);
    }

Originally posted by @cblh in #4079 (comment)

Metadata

Metadata

Assignees

Labels

C-bugCategory - Bug

Type

No type

Priority

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions