tmsvg / pear-tree

A Vim auto-pair plugin that supports multi-character pairs, intelligent matching, and more
MIT License
392 stars 12 forks source link

`not_at` seemingly not working if matching whitespace #58

Open TheOmegaCarrot opened 2 years ago

TheOmegaCarrot commented 2 years ago

Goal: Have a pair of open/close characters which only autopair if not preceded by a space. Why: Autopairing with C++ templates (leveraging my habit of always preceding an operator '<' with a space, and never preceding a template opening '<' with a space)

Hopefully there is an actual issue here, and not me making a foolish mistake.

Cases:

'<': {'closer': '>', 'not_at': ['\w'] Behavior: does not pair after word characters (expected)

'<': {'closer': '>', 'not_at': ['\s'] Expected behavior: do not pair after space Actual behavior: pairs unconditionally

Input: if ( a < b) Output: if ( a < b> ) Expected: if ( a < b )

Input: std::vector<int Output: std::vector<int> Expected: std::vector<int>

'<': {'closer': '>', 'not_at': [' '] Expected behavior: do not pair after space Actual behavior: pairs unconditionally

Input: if ( a < b) Output: if ( a < b> ) Expected: if ( a < b )

Input: std::vector<int Output: std::vector<int> Expected: std::vector<int>

'<': {'closer': '>', 'not_at': ['[ ]'] Expected behavior: do not pair after space Actual behavior: pairs unconditionally

Input: if ( a < b) Output: if ( a < b> ) Expected: if ( a < b )

Input: std::vector<int Output: std::vector<int> Expected: std::vector<int>

'<': {'closer': '>', 'not_at': ['[:space:]'] Expected behavior: do not pair after space Actual behavior: pairs unconditionally

Input: if ( a < b) Output: if ( a < b> ) Expected: if ( a < b )

Input: std::vector<int Output: std::vector<int> Expected: std::vector<int>

'<': {'closer': '>', 'not_at': ['[^\w]'] Expected behavior: do not pair after word character Actual behavior: pairs after word character

Input: if ( a < b) Output: if ( a < b> ) Expected: if ( a < b )

Input: std::vector<int Output: std::vector<int Expected: std::vector<int>

'<': {'closer': '>', 'not_at': ['[^a-zA-Z0-9]'] Expected behavior: do not pair after above character set Actual behavior: pairs unconditionally

Input: if ( a < b) Output: if ( a < b> ) Expected: if ( a < b )

Input: std::vector<int Output: std::vector<int> Expected: std::vector<int>

TheOmegaCarrot commented 2 years ago

Workaround: '<': {'closer': '>'}, ' <': {'closer': ''}

Expected behavior: do not pair after space Actual behavior: do not pair after space Downside: Seems real jank

Input: if ( a < b) Output: if ( a < b ) Expected: if ( a < b )

Input: std::vector<int Output: std::vector<int> Expected: std::vector<int>