@@ -218,6 +218,9 @@ Intended for internal use."
218218 (let ((chunk (swift-mode:chunk-after)))
219219 (when chunk
220220 (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))
221224 (let ((pos (point ))
222225 (previous-token (save-excursion
223226 (forward-comment (- (point )))
@@ -289,7 +292,7 @@ Statements include comments on the same line.
289292Intended for internal use."
290293 (let ((pos (point )))
291294 (swift-mode:beginning-of-statement)
292- (when (eq pos (point ))
295+ (when (<= pos (point ))
293296 (swift-mode:backward-token-or-list)
294297 (swift-mode:beginning-of-statement))))
295298
@@ -336,6 +339,9 @@ Intended for internal use."
336339 (let ((chunk (swift-mode:chunk-after)))
337340 (when chunk
338341 (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))
339345 (forward-comment (point-max ))
340346 (let ((pos (point ))
341347 token)
@@ -808,6 +814,17 @@ In comments or strings, skip a sentence. Otherwise, skip a stateement."
808814 " Skip forward a sentence in a comment.
809815
810816IS-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 )))
811828 (let ((current-buffer (current-buffer ))
812829 (pos (point ))
813830 (comment-block-end-position
@@ -824,7 +841,8 @@ IS-SINGLE-LINE should be non-nil when called inside a single-line comment."
824841 (if is-single-line
825842 (while (re-search-forward " ^[ \t ]*/+[ \t ]*" nil t )
826843 (replace-match " " ))
827- (when (looking-at " \\ *+" )
844+ (when (and (not (looking-at " \\ *+/" ))
845+ (looking-at " \\ *+" ))
828846 (replace-match " " ))))
829847 ; ; Forwards sentence.
830848 (let ((old-position (point )))
@@ -848,7 +866,14 @@ IS-SINGLE-LINE should be non-nil when called inside a single-line comment."
848866 (forward-line -1 )
849867 (setq line-count (1+ line-count)))))
850868 (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))
852877 (or (/= (point ) pos)
853878 (progn
854879 (goto-char comment-block-end-position)
@@ -901,7 +926,7 @@ IS-SINGLE-LINE should be non-nil when called inside a single-line comment."
901926 (or (< (point ) pos)
902927 (progn
903928 (goto-char comment-block-beginning-position)
904- (swift-mode:backward-sentence-inside-code nil )))))
929+ (swift-mode:backward-sentence-inside-code t )))))
905930
906931(defmacro swift-mode:with-temp-comment-buffer (&rest body )
907932 " Eval BODY inside a temporary buffer keeping sentence related variables."
@@ -1098,10 +1123,7 @@ the end of a sentence, keep the position."
10981123 (progn (swift-mode:end-of-statement) t )
10991124 (let ((pos (point )))
11001125 (swift-mode:forward-statement)
1101- (or (not (eobp ))
1102- (progn
1103- (forward-comment (- (point )))
1104- (< pos (point ))))))))
1126+ (< pos (point ))))))
11051127
11061128(defun swift-mode:backward-sentence-inside-code
11071129 (&optional keep-position-if-at-beginning-of-sentence)
@@ -1118,10 +1140,7 @@ already at the beginning of a sentence, keep the position."
11181140 (progn (swift-mode:beginning-of-statement) t )
11191141 (let ((pos (point )))
11201142 (swift-mode:backward-statement)
1121- (or (not (bobp ))
1122- (progn
1123- (forward-comment (point-max ))
1124- (< (point ) pos)))))))
1143+ (< (point ) pos)))))
11251144
11261145(defun swift-mode:kill-sentence (&optional arg )
11271146 " Kill from the point to the end of sentences.
0 commit comments