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

Some regular expressions no longer work in macro triggers #2728

Closed
UhrMensch opened this issue Dec 5, 2022 · 1 comment
Closed

Some regular expressions no longer work in macro triggers #2728

UhrMensch opened this issue Dec 5, 2022 · 1 comment

Comments

@UhrMensch
Copy link

Environment

  • TeXstudio: 4.3.0 and newer
  • Qt: 6
  • OS: Windows 10
  • TeX distribution: miktex

Description

Since version 4.3.0, some macro triggers which worked in version 4.2.3 do not work any more. It seems that triggers with a look-ahead expression (?<=...) containing one of the quantifiers ? * + or a | sign (non-escaped) do not work at all. On top of that, ? * + in outside look-ahead expressions are now non-greedy.

Besides that, the look-ahead group (?<=...) is no longer captured, i.e. it cannot be referenced by triggerMatches[...] in the trigger script, and hence the index of all other captured groups is 1 lower than it used to be. (This might be on purpose since it is consistent with the behaviour in the Search/Replace dialogue.)

Note: Due to this bug, I never used versions 4.3.0, 4.3.1, 4.4.0, and 4.4.1 and thus do not know if the exact behaviour changed after version 4.3.0. The above text describes the behaviour in version 4.4.0.

Expected behavior

The regular expressions
(?<=a+)b
(?<=a*)b
(?<=a|aa)b
(?<=a?)b
all activate a trigger when "ab" is typed.

a?b replaces "ab" by the trigger contents.
a*b replaces "ab" by the trigger contents.
a+b replaces "aab" by the trigger contents.

Actual behavior

The regular expressions
(?<=a+)b
(?<=a*)b
(?<=a|aa)b
(?<=a?)b
seem to never activate a trigger at all any more.

a?b still activates the macro when "b" is typed, but when "ab" is typed, only "b" is matched and replaced.
a*b still activates the macro when "b" is typed, but when "ab" is typed, only "b" is matched and replaced.
a+b still activates the macro when "ab" is typed, but when "aab" is typed, only "ab" is matched and replaced.

ca+b still works, matching arbitrarily many "a"s
(c|a)b still works, too.

How to reproduce

The issue is completely reproducible on my system and does not depend on the actual letters or expressions used.

@sunderme
Copy link
Member

sunderme commented Dec 5, 2022

same as #2729
only valid regex is (?<=a|aa)b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants