diff options
author | ridiculousfish <corydoras@ridiculousfish.com> | 2014-11-25 10:43:03 -0800 |
---|---|---|
committer | ridiculousfish <corydoras@ridiculousfish.com> | 2014-11-25 10:43:03 -0800 |
commit | 8526a8294742ca7be585207bed71a25e3799433a (patch) | |
tree | 53a2be746911d8483cd4c6613cc906523aba28aa /tokenizer.cpp | |
parent | 94a3203c74802d207c05d9bbfea57ddfd8aff0ee (diff) |
Fix for issue where fish_indent would lose blank lines
Diffstat (limited to 'tokenizer.cpp')
-rw-r--r-- | tokenizer.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/tokenizer.cpp b/tokenizer.cpp index 29db04bd..16929a14 100644 --- a/tokenizer.cpp +++ b/tokenizer.cpp @@ -101,6 +101,7 @@ tokenizer_t::tokenizer_t(const wchar_t *b, tok_flags_t flags) : buff(NULL), orig this->accept_unfinished = !!(flags & TOK_ACCEPT_UNFINISHED); this->show_comments = !!(flags & TOK_SHOW_COMMENTS); this->squash_errors = !!(flags & TOK_SQUASH_ERRORS); + this->show_blank_lines = !!(flags & TOK_SHOW_BLANK_LINES); this->has_next = (*b != L'\0'); this->orig_buff = this->buff = b; @@ -562,7 +563,6 @@ const wchar_t *tok_get_desc(int type) return _(tok_desc[type]); } - void tok_next(tokenizer_t *tok) { @@ -628,18 +628,18 @@ void tok_next(tokenizer_t *tok) break; case 13: // carriage return case L'\n': + case L';': + tok->last_type = TOK_END; + tok->buff++; // Hack: when we get a newline, swallow as many as we can // This compresses multiple subsequent newlines into a single one - while (*tok->buff == L'\n' || *tok->buff == 13 || *tok->buff == ' ' || *tok->buff == '\t') + if (! tok->show_blank_lines) { - tok->buff++; + while (*tok->buff == L'\n' || *tok->buff == 13 /* CR */ || *tok->buff == ' ' || *tok->buff == '\t') + { + tok->buff++; + } } - tok->last_type = TOK_END; - break; - - case L';': - tok->last_type = TOK_END; - tok->buff++; break; case L'&': tok->last_type = TOK_BACKGROUND; |