Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2011-07-26 12:13:27 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2011-07-26 12:13:27 +0400
commit7c9033d606a35dd4311e9f84b06b013e5cb7712a (patch)
treedc0e2c008be76ac9d10c4e410863e36e94d2a71f
parent9e1a5531274e6b00b877ef924994ceae8ba956e3 (diff)
Fix #28087: Opening files in the text editor ignores the last newline '\n'
It was tricky conversion of file buffer to text lines. Should work fine now.
-rw-r--r--source/blender/blenkernel/intern/text.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c
index da329503c9f..56723476251 100644
--- a/source/blender/blenkernel/intern/text.c
+++ b/source/blender/blenkernel/intern/text.c
@@ -400,7 +400,13 @@ Text *add_text(const char *file, const char *relpath)
llen++;
}
- if (llen!=0 || ta->nlines==0) {
+ /* create new line in cases:
+ - rest of line (if last line in file hasn't got \n terminator).
+ in this case content of such line would be used to fill text line buffer
+ - file is empty. in this case new line is needed to start editing from.
+ - last characted in buffer is \n. in this case new line is needed to
+ deal with newline at end of file. (see [#28087]) (sergey) */
+ if (llen!=0 || ta->nlines==0 || buffer[len-1]=='\n') {
tmp= (TextLine*) MEM_mallocN(sizeof(TextLine), "textline");
tmp->line= (char*) MEM_mallocN(llen+1, "textline_string");
tmp->format= NULL;