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

add key selector argument to replace #74

Merged
merged 1 commit into from
Feb 6, 2021
Merged

add key selector argument to replace #74

merged 1 commit into from
Feb 6, 2021

Conversation

mattlqx
Copy link
Collaborator

@mattlqx mattlqx commented Feb 6, 2021

this adds a -s/--key-selector argument to the replace command. in
non-regexp mode, it will specify a complete key to match against. in
regexp mode, if the key selector yields any matches it will be
considered be successful. in this case, replacements will be evaluated
against that key-value pair. the key selector match will also be highlighted
in the display.

this pull also fixes two issues:

  • improper evaluation of the add/remove markup on a line diff during
    replace
  • indexes being generated for regexps (index+length) did not match the
    indexes being generated for substrings (start&end) resulting in a
    panic for matches longer than half the string

Screen Shot 2021-02-05 at 20 25 27

after confirmation:
Screen Shot 2021-02-05 at 20 25 55

@fishi0x01
Copy link
Owner

fishi0x01 commented Feb 6, 2021

Fixes #72

As usual, this looks amazing @mattlqx. Thank you 🙇

One little remark: Codeclimate is complaining about formatting. Can you run gofmt -w cli/search.go to format the code?

this adds a `-s`/`--key-selector` argument to the `replace` command. in
non-regexp mode, it will specify a complete key to match against. in
regexp mode, if the key selector yields any matches it will be
considered be successful. in this case, replacements will be evaluated
against that key-value pair.

this pull also fixes two issues:
- improper evaluation of the add/remove markup on a line diff during
  replace
- indexes being generated for regexps (index+length) did not match the
  indexes being generated for substrings (start&end) resulting in a
  panic for matches longer than half the string
@fishi0x01 fishi0x01 merged commit d4c496e into fishi0x01:master Feb 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants