Skip to content

Commit abc68c8

Browse files
committed
Improve logic
1 parent 8b6c8b9 commit abc68c8

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

rust-auto-use.el

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,24 @@
99
(defun rust-auto-use/insert-use-line (use-line)
1010
(save-excursion
1111
(beginning-of-buffer)
12-
(forward-line -1)
13-
(forward-paragraph)
14-
(while (not (or (looking-at "use ")
15-
(looking-at "[[:space:]]*$")))
16-
(forward-line))
12+
(while (or (looking-at "/")
13+
(looking-at "extern"))
14+
(forward-line)
15+
(beginning-of-line))
1716

18-
(newline)
19-
(insert use-line)))
20-
21-
(defun rust-auto-use/deduce-use-line ()
22-
(let ((symbol (symbol-at-point)))
23-
(let ((cached-result (gethash symbol rust-auto-use/symbol-cache)))
24-
(if cached-result
25-
cached-result
26-
(rust-auto-use/save-result symbol (rust-auto-use/parse-import-string-from-symbol symbol))))))
17+
(insert use-line)
18+
(newline)
19+
(if (and (not (looking-at "[[:space:]]*$"))
20+
(not (looking-at "use ")))
21+
(newline))))
22+
23+
24+
(defun rust-auto-use/deduce-use-line ()
25+
(let ((symbol (symbol-at-point)))
26+
(let ((cached-result (gethash symbol rust-auto-use/symbol-cache)))
27+
(if cached-result
28+
cached-result
29+
(rust-auto-use/save-result symbol (rust-auto-use/parse-import-string-from-symbol symbol))))))
2730

2831

2932
(defun rust-auto-use/parse-import-string-from-symbol (symbol)

0 commit comments

Comments
 (0)