diff options
| author | Dmitry Gutov | 2015-04-03 06:37:12 +0300 |
|---|---|---|
| committer | Dmitry Gutov | 2015-04-03 06:37:31 +0300 |
| commit | f2fbd4b71236ca5559b93eb2baf1a7671442eef9 (patch) | |
| tree | c8707f80b57ae3f76510046dc3874f6bb08c0101 | |
| parent | 839decd9ecbfa4ec4183ac69037f5aa882bdc47c (diff) | |
| download | emacs-f2fbd4b71236ca5559b93eb2baf1a7671442eef9.tar.gz emacs-f2fbd4b71236ca5559b93eb2baf1a7671442eef9.zip | |
js-mode: Don't indent inside a multiline string literal
* lisp/progmodes/js.el (js-indent-line): Do nothing when bol is inside
a string (https://github.com/mooz/js2-mode/issues/227).
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/progmodes/js.el | 3 | ||||
| -rw-r--r-- | test/indent/js.js | 5 |
3 files changed, 12 insertions, 1 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 38e45d063a4..b004a2bba96 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2015-04-03 Dmitry Gutov <dgutov@yandex.ru> | ||
| 2 | |||
| 3 | * progmodes/js.el (js-indent-line): Do nothing when bol is inside | ||
| 4 | a string (https://github.com/mooz/js2-mode/issues/227). | ||
| 5 | |||
| 1 | 2015-04-02 Stefan Monnier <monnier@iro.umontreal.ca> | 6 | 2015-04-02 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 7 | ||
| 3 | * abbrev.el (define-abbrev-table): Treat a non-string "docstring" as | 8 | * abbrev.el (define-abbrev-table): Treat a non-string "docstring" as |
diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index ff002983d12..f6cfa2e44d7 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el | |||
| @@ -2002,7 +2002,8 @@ indentation is aligned to that column." | |||
| 2002 | (let* ((parse-status | 2002 | (let* ((parse-status |
| 2003 | (save-excursion (syntax-ppss (point-at-bol)))) | 2003 | (save-excursion (syntax-ppss (point-at-bol)))) |
| 2004 | (offset (- (point) (save-excursion (back-to-indentation) (point))))) | 2004 | (offset (- (point) (save-excursion (back-to-indentation) (point))))) |
| 2005 | (indent-line-to (js--proper-indentation parse-status)) | 2005 | (unless (nth 3 parse-status) |
| 2006 | (indent-line-to (js--proper-indentation parse-status))) | ||
| 2006 | (when (> offset 0) (forward-char offset)))) | 2007 | (when (> offset 0) (forward-char offset)))) |
| 2007 | 2008 | ||
| 2008 | ;;; Filling | 2009 | ;;; Filling |
diff --git a/test/indent/js.js b/test/indent/js.js index ad7cb56a277..2120233259a 100644 --- a/test/indent/js.js +++ b/test/indent/js.js | |||
| @@ -64,6 +64,11 @@ b += | |||
| 64 | baz(`http://foo.bar/${tee}`) | 64 | baz(`http://foo.bar/${tee}`) |
| 65 | .qux(); | 65 | .qux(); |
| 66 | 66 | ||
| 67 | `multiline string | ||
| 68 | contents | ||
| 69 | are kept | ||
| 70 | unchanged!` | ||
| 71 | |||
| 67 | // Local Variables: | 72 | // Local Variables: |
| 68 | // indent-tabs-mode: nil | 73 | // indent-tabs-mode: nil |
| 69 | // js-indent-level: 2 | 74 | // js-indent-level: 2 |