Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The adjacent span is ignored in fixer #4204

Closed
mysteryven opened this issue Jul 11, 2024 · 0 comments · Fixed by #4217
Closed

The adjacent span is ignored in fixer #4204

mysteryven opened this issue Jul 11, 2024 · 0 comments · Fixed by #4217
Assignees
Labels
C-bug Category - Bug

Comments

@mysteryven
Copy link
Contributor

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category - Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant