-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Additional indentation recovery for newline and case construction.
The newline indentation uses the indentation of the next non-comment sibling node. When this node was an ERROR, the catch-all indentation rule was matched which placed the newline at column 0. Now, ERROR nodes are handled by the indentation error recovery logic and newline indentation prior to an ERROR node will be chosen according to this logic. The "end" corresponding to a case construction was not being properly indented to the same level as the beginning of the case construction, within the indentation error recovery logic. This has been corrected. Additional tests have been added to check indentation error recovery logic for "end" nodes of a project, package and case construction declaration. A test was also added to check for newline indentation just prior to an ERROR node.
- Loading branch information
Showing
2 changed files
with
70 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
|
||
;; Author: Troy Brown <[email protected]> | ||
;; Created: February 2023 | ||
;; Version: 0.6.4 | ||
;; Version: 0.6.5 | ||
;; Keywords: gpr gnat ada languages tree-sitter | ||
;; URL: https://github.com/brownts/gpr-ts-mode | ||
;; Package-Requires: ((emacs "29.1")) | ||
|
@@ -326,7 +326,11 @@ If OP is nil or \\='anchor\\=', determine recovery anchor. If OP is | |
(let ((compound-alist | ||
`(("when" . ( :compound-type "case_item")) | ||
("case" . ( :compound-type "case_construction" | ||
:offset gpr-ts-mode-indent-when-offset)) | ||
:offset | ||
(lambda (_anchor) | ||
(if (and ,node (string-equal (treesit-node-type ,node) "end")) | ||
0 | ||
gpr-ts-mode-indent-when-offset)))) | ||
("package" . ( :compound-type "package_declaration" | ||
:offset | ||
(lambda (_anchor) | ||
|
@@ -588,9 +592,10 @@ Return nil if no child of that type is found." | |
(gpr-ts-mode--anchor-first-sibling-matching "case_item") | ||
gpr-ts-mode-indent-offset) | ||
|
||
;; Parent ERROR recovery rules. | ||
;; Error recovery rules. | ||
|
||
((and (or (parent-is "ERROR") | ||
(node-is "ERROR") | ||
(gpr-ts-mode--prev-sibling-matches-p "ERROR")) | ||
(gpr-ts-mode--indent-error-recovery-exists-p)) | ||
(gpr-ts-mode--anchor-of-indent-error-recovery) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters