[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 1bee3a3 39/42: Fix #979: grok curly braces with LSP-style
From: |
Noam Postavsky |
Subject: |
[elpa] master 1bee3a3 39/42: Fix #979: grok curly braces with LSP-style escaping |
Date: |
Sun, 22 Dec 2019 17:38:03 -0500 (EST) |
branch: master
commit 1bee3a33c77d1a61c331461750e01c4f6fa85417
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>
Fix #979: grok curly braces with LSP-style escaping
* yasnippet-tests.el (escaping-for-lsp-style-snippet-syntax): New
test.
* yasnippet.el (yas--field-parse-create): rework real-match-end-0
calculation.
---
yasnippet-tests.el | 14 ++++++++++++++
yasnippet.el | 9 ++++++++-
2 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/yasnippet-tests.el b/yasnippet-tests.el
index 6a306ee..f7ca2bb 100644
--- a/yasnippet-tests.el
+++ b/yasnippet-tests.el
@@ -781,6 +781,20 @@ mapconcat #'(lambda (arg)
(yas-expand-snippet "Look ma! ${1:`(yas-selected-text)`} OK?")
(should (string= (yas--buffer-contents) "Look ma! He)}o world! OK?")))))
+(ert-deftest escaping-for-lsp-style-snippet-syntax ()
+ "See Github #979."
+ (should
+ (string= (with-temp-buffer
+ (yas-minor-mode 1)
+ (yas-expand-snippet
+ "Printf(${1:format string}, ${2:args ...interface{\\}})${0}")
+ (yas--buffer-contents))
+ (with-temp-buffer
+ (yas-minor-mode 1)
+ (yas-expand-snippet
+ "Printf(${1:format string}, ${2:args ...interface\\{\\}})${0}")
+ (yas--buffer-contents)))))
+
(ert-deftest insert-snippet-with-backslashes-in-active-field ()
;; This test case fails if `yas--inhibit-overlay-hooks' is not bound
;; in `yas-expand-snippet' (see Github #844).
diff --git a/yasnippet.el b/yasnippet.el
index 02886ca..d980bf1 100644
--- a/yasnippet.el
+++ b/yasnippet.el
@@ -4730,7 +4730,14 @@ When multiple expressions are found, only the last one
counts."
;;
(save-excursion
(while (re-search-forward yas--field-regexp nil t)
- (let* ((real-match-end-0 (yas--scan-sexps (1+ (match-beginning 0)) 1))
+ (let* ((brace-scan (yas--scan-sexps (1+ (match-beginning 0)) 1))
+ ;; if the `brace-scan' didn't reach a brace, we have a
+ ;; snippet with invalid escaping, probably a closing
+ ;; brace escaped with two backslashes (github#979). But
+ ;; be lenient, because we can.
+ (real-match-end-0 (if (eq ?} (char-before brace-scan))
+ brace-scan
+ (point)))
(number (and (match-string-no-properties 1)
(string-to-number (match-string-no-properties 1))))
(brand-new-field (and real-match-end-0
- [elpa] master 03aa561 19/42: * doc/snippet-organization.org: Fix typo., (continued)
- [elpa] master 03aa561 19/42: * doc/snippet-organization.org: Fix typo., Noam Postavsky, 2019/12/22
- [elpa] master 9f51cf2 17/42: Register snippet movement comments for eldoc, Noam Postavsky, 2019/12/22
- [elpa] master 6a738b5 29/42: ; doc/faq.org: Fix example keybinding code., Noam Postavsky, 2019/12/22
- [elpa] master 476bc77 35/42: Fix snippet undo, Noam Postavsky, 2019/12/22
- [elpa] master c432e78 31/42: Fix field adjustment on deletion, Noam Postavsky, 2019/12/22
- [elpa] master f056a4d 33/42: Minor code shuffling and commenting, Noam Postavsky, 2019/12/22
- [elpa] master bd3572a 36/42: Handle multiple uses of yas-auto-next, Noam Postavsky, 2019/12/22
- [elpa] master e45e3de 34/42: * doc/faq.org: yas-prev should be yas-prev-field, Noam Postavsky, 2019/12/22
- [elpa] master a66f15e 38/42: Fix yas-insert-snippet for keyless snippets, Noam Postavsky, 2019/12/22
- [elpa] master d91dd66 37/42: * yasnippet.el (yas--extra-modes): Move alias before def, Noam Postavsky, 2019/12/22
- [elpa] master 1bee3a3 39/42: Fix #979: grok curly braces with LSP-style escaping,
Noam Postavsky <=
- [elpa] master 3bf9a3b 41/42: Release 0.14.0, Noam Postavsky, 2019/12/22
- [elpa] master 4046f61 40/42: * yasnippet.el (yas-field-highlight-face): Remove redundant quote., Noam Postavsky, 2019/12/22
- [elpa] master 32f3512 42/42: * packages/yasnippet: Merge 0.14.0 from upstream., Noam Postavsky, 2019/12/22