@@ -218,6 +218,9 @@ Intended for internal use."
218
218
(let ((chunk (swift-mode:chunk-after)))
219
219
(when chunk
220
220
(goto-char (swift-mode:chunk:start chunk))))
221
+ (when (and (eq (char-syntax (or (char-after ) ?. )) ?w )
222
+ (eq (char-syntax (or (char-before ) ?. )) ?w ))
223
+ (swift-mode:forward-token))
221
224
(let ((pos (point ))
222
225
(previous-token (save-excursion
223
226
(forward-comment (- (point )))
@@ -289,7 +292,7 @@ Statements include comments on the same line.
289
292
Intended for internal use."
290
293
(let ((pos (point )))
291
294
(swift-mode:beginning-of-statement)
292
- (when (eq pos (point ))
295
+ (when (<= pos (point ))
293
296
(swift-mode:backward-token-or-list)
294
297
(swift-mode:beginning-of-statement))))
295
298
@@ -336,6 +339,9 @@ Intended for internal use."
336
339
(let ((chunk (swift-mode:chunk-after)))
337
340
(when chunk
338
341
(goto-char (swift-mode:chunk:start chunk))))
342
+ (when (and (eq (char-syntax (or (char-after ) ?. )) ?w )
343
+ (eq (char-syntax (or (char-before ) ?. )) ?w ))
344
+ (swift-mode:backward-token))
339
345
(forward-comment (point-max ))
340
346
(let ((pos (point ))
341
347
token)
@@ -808,6 +814,17 @@ In comments or strings, skip a sentence. Otherwise, skip a stateement."
808
814
" Skip forward a sentence in a comment.
809
815
810
816
IS-SINGLE-LINE should be non-nil when called inside a single-line comment."
817
+ (when (and (not is-single-line)
818
+ (eq (char-before ) ?/ )
819
+ (eq (char-after ) ?* ))
820
+ (forward-char ))
821
+ (when (and is-single-line
822
+ (< (point ) (save-excursion
823
+ (forward-line 0 )
824
+ (if (looking-at " \\ s *//+" )
825
+ (match-end 0 )
826
+ (point )))))
827
+ (goto-char (match-end 0 )))
811
828
(let ((current-buffer (current-buffer ))
812
829
(pos (point ))
813
830
(comment-block-end-position
@@ -824,7 +841,8 @@ IS-SINGLE-LINE should be non-nil when called inside a single-line comment."
824
841
(if is-single-line
825
842
(while (re-search-forward " ^[ \t ]*/+[ \t ]*" nil t )
826
843
(replace-match " " ))
827
- (when (looking-at " \\ *+" )
844
+ (when (and (not (looking-at " \\ *+/" ))
845
+ (looking-at " \\ *+" ))
828
846
(replace-match " " ))))
829
847
; ; Forwards sentence.
830
848
(let ((old-position (point )))
@@ -848,7 +866,14 @@ IS-SINGLE-LINE should be non-nil when called inside a single-line comment."
848
866
(forward-line -1 )
849
867
(setq line-count (1+ line-count)))))
850
868
(forward-line line-count)
851
- (goto-char (- (line-end-position ) offset-from-line-end))
869
+ (goto-char (- (if (and (not is-single-line)
870
+ (eq (line-end-position )
871
+ (save-excursion
872
+ (goto-char comment-block-end-position)
873
+ (line-end-position ))))
874
+ comment-block-end-position
875
+ (line-end-position ))
876
+ offset-from-line-end))
852
877
(or (/= (point ) pos)
853
878
(progn
854
879
(goto-char comment-block-end-position)
@@ -901,7 +926,7 @@ IS-SINGLE-LINE should be non-nil when called inside a single-line comment."
901
926
(or (< (point ) pos)
902
927
(progn
903
928
(goto-char comment-block-beginning-position)
904
- (swift-mode:backward-sentence-inside-code nil )))))
929
+ (swift-mode:backward-sentence-inside-code t )))))
905
930
906
931
(defmacro swift-mode:with-temp-comment-buffer (&rest body )
907
932
" Eval BODY inside a temporary buffer keeping sentence related variables."
@@ -1098,10 +1123,7 @@ the end of a sentence, keep the position."
1098
1123
(progn (swift-mode:end-of-statement) t )
1099
1124
(let ((pos (point )))
1100
1125
(swift-mode:forward-statement)
1101
- (or (not (eobp ))
1102
- (progn
1103
- (forward-comment (- (point )))
1104
- (< pos (point ))))))))
1126
+ (< pos (point ))))))
1105
1127
1106
1128
(defun swift-mode:backward-sentence-inside-code
1107
1129
(&optional keep-position-if-at-beginning-of-sentence)
@@ -1118,10 +1140,7 @@ already at the beginning of a sentence, keep the position."
1118
1140
(progn (swift-mode:beginning-of-statement) t )
1119
1141
(let ((pos (point )))
1120
1142
(swift-mode:backward-statement)
1121
- (or (not (bobp ))
1122
- (progn
1123
- (forward-comment (point-max ))
1124
- (< (point ) pos)))))))
1143
+ (< (point ) pos)))))
1125
1144
1126
1145
(defun swift-mode:kill-sentence (&optional arg )
1127
1146
" Kill from the point to the end of sentences.
0 commit comments