Skip to content

onDidSaveDocument() regex update never successful #5

Description

@Nos78

The code for updating the modified by author & time via sub-string replacement using a regex never seems to work, and always falls back to constructing the line via the hard-coded string.

This means that this part of any custom user template would be overwritten by a hard-coded string (so the user can never change the two modified by lines)... it also is a waste of CPU time, performing code that will never work. This would be noticable if the user had added text before or after the @Modified by or @Modified at on the same line, this text would be overwritten on the next save.

Additionally, both regexs for performing the sub-replacement are hard-coded and the check for if we are on either of those lines are all hard-coded. This makes it impossible to change the actual label being searched for. But it also looks like an additional layer of complexity. We check for the index of "@Modified by/at" then we test the regex for the same string, which fails, so we just overwrite the line by completely reconstructing it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions