[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/yaml-mode 37da7fb9be 1/2: Do not modify the buffer in `yam
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/yaml-mode 37da7fb9be 1/2: Do not modify the buffer in `yaml-indent-line` unless necessary |
Date: |
Wed, 29 Mar 2023 04:02:00 -0400 (EDT) |
branch: elpa/yaml-mode
commit 37da7fb9becc0b1d35d3077e9bc3f62b741c917d
Author: Konstantin Kharlamov <Hi-Angel@yandex.ru>
Commit: Konstantin Kharlamov <Hi-Angel@yandex.ru>
Do not modify the buffer in `yaml-indent-line` unless necessary
Calling (yaml-indent-line) for the first time on a line that the
function already deems indented correctly results in the buffer
getting modified even though there was nothing to modify. This is
because the function unconditionally removes space at the beginning of
line and then re-indents text back.
Fix this by replacing the `bol` + `delete-horizontal-space` + `indent-to`
combination with a call to `indent-line-to` which does the right
thing.
---
yaml-mode.el | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/yaml-mode.el b/yaml-mode.el
index fc46e0582a..1cfef236dd 100644
--- a/yaml-mode.el
+++ b/yaml-mode.el
@@ -368,11 +368,9 @@ back-dent the line by `yaml-indent-offset' spaces. On
reaching column
(let ((ci (current-indentation))
(need (yaml-compute-indentation)))
(save-excursion
- (beginning-of-line)
- (delete-horizontal-space)
(if (and (equal last-command this-command) (/= ci 0))
- (indent-to (* (/ (- ci 1) yaml-indent-offset) yaml-indent-offset))
- (indent-to need)))
+ (indent-line-to (* (/ (- ci 1) yaml-indent-offset)
yaml-indent-offset))
+ (indent-line-to need)))
(if (< (current-column) (current-indentation))
(forward-to-indentation 0))))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [nongnu] elpa/yaml-mode 37da7fb9be 1/2: Do not modify the buffer in `yaml-indent-line` unless necessary,
ELPA Syncer <=