@@ -225,11 +225,15 @@ declaration and its offset is `swift-mode:basic-offset'."
225225 (swift-mode:indentation (point ) 0 )))))
226226
227227(defun swift-mode:calculate-indent-of-multiline-string ()
228- " Return the indentation of the current line inside a multiline string."
228+ " Return the indentation of the current line inside a multiline string.
229+
230+ Also used for regexes."
229231 (back-to-indentation )
230232 (let ((string-beginning-position
231233 (save-excursion (swift-mode:beginning-of-string))))
232- (if (looking-at " \"\"\" " )
234+ (if (and (looking-at " \\ (\"\"\" \\ |/\\ )#*" )
235+ (equal (get-text-property (1- (match-end 0 )) 'syntax-table )
236+ (string-to-syntax " |" )))
233237 ; ; The last line.
234238 (progn
235239 (goto-char string-beginning-position)
@@ -240,13 +244,13 @@ declaration and its offset is `swift-mode:basic-offset'."
240244 (swift-mode:goto-non-interpolated-expression-bol)
241245 (back-to-indentation )
242246 (if (<= (point ) string-beginning-position)
243- ; ; The cursor was on the 2nd line of the comment , so aligns with
247+ ; ; The cursor was on the 2nd line of the string , so aligns with
244248 ; ; that line with offset.
245249 (progn
246250 (goto-char string-beginning-position)
247251 (swift-mode:calculate-indent-of-expression
248252 swift-mode:multiline-statement-offset))
249- ; ; The cursor was on the 3rd or following lines of the comment , so
253+ ; ; The cursor was on the 3rd or following lines of the string , so
250254 ; ; aligns with a non-empty preceding line.
251255 (if (and (bolp ) (eolp ))
252256 ; ; The cursor is on an empty line, so seeks a non-empty-line.
0 commit comments