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

Fix range must count the current text length, not the replacement's #2

Closed
fnando opened this issue Jul 16, 2021 · 2 comments · Fixed by #3 · May be fixed by #13
Closed

Fix range must count the current text length, not the replacement's #2

fnando opened this issue Jul 16, 2021 · 2 comments · Fixed by #3 · May be fixed by #13
Labels
Type: Bug Bug or Bug fixes

Comments

@fnando
Copy link

fnando commented Jul 16, 2021

I'm implementing a plugin that applies textlint fixes, and noticed that the range is being incorrectly computed.

See the example below:

$ echo '2021-07-02 (Thursday)' | textlint --format json --config samples/.textlintrc.json --stdin --stdin-filename file.md | jq
[
  {
    "messages": [
      {
        "type": "lint",
        "ruleId": "date-weekday-mismatch",
        "message": "2021-07-02 (Thursday) mismatch weekday.\n2021-07-02 (Thursday) => 2021-07-02 (Friday)",
        "index": 12,
        "line": 1,
        "column": 13,
        "severity": 2,
        "fix": {
          "range": [
            12,
            18
          ],
          "text": "Friday"
        }
      }
    ],
    "filePath": "<markdown>"
  }
]

The range should be within 8 characters (Thursday), instead of 6. If I apply the suggested range, I'll end up with Fridayay.

@azu azu added the Type: Bug Bug or Bug fixes label Jul 16, 2021
azu added a commit that referenced this issue Jul 16, 2021
@azu azu closed this as completed in #3 Jul 16, 2021
azu added a commit that referenced this issue Jul 16, 2021
* fix: correct replace range

fix #2

* CI: use GitHub Actions
@azu
Copy link
Member

azu commented Jul 16, 2021

@fnando
Copy link
Author

fnando commented Jul 16, 2021

Thanks for acting so quickly! <3 <3 <3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Bug or Bug fixes
Projects
None yet
2 participants