Merge lp:~tintou/scratch/fix-doc-ending into lp:~elementary-apps/scratch/scratch

Proposed by Corentin Noël
Status: Merged
Approved by: Corentin Noël
Approved revision: 1467
Merged at revision: 1472
Proposed branch: lp:~tintou/scratch/fix-doc-ending
Merge into: lp:~elementary-apps/scratch/scratch
Diff against target: 49 lines (+9/-7)
2 files modified
src/Services/Document.vala (+1/-3)
src/Services/FileHandler.vala (+8/-4)
To merge this branch: bzr merge lp:~tintou/scratch/fix-doc-ending
Reviewer Review Type Date Requested Status
elementary Apps team Pending
Review via email: mp+253007@code.launchpad.net

Commit message

Do not modify ending of documents.

Description of the change

Do not modify ending of documents.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Services/Document.vala'
2--- src/Services/Document.vala 2015-02-23 00:37:59 +0000
3+++ src/Services/Document.vala 2015-03-15 22:51:28 +0000
4@@ -277,9 +277,7 @@
5 // Replace old content with the new one
6 try {
7 FileOutputStream fostream = file.replace (null, false, 0);
8- fostream.write (this.source_view.buffer.text.data);
9- uint8[] eof = { '\n' };
10- fostream.write (eof);
11+ fostream.write (this.source_view.buffer.text.data);
12 } catch (Error e) {
13 warning ("Cannot save \"%s\": %s", get_basename (), e.message);
14 return false;
15
16=== modified file 'src/Services/FileHandler.vala'
17--- src/Services/FileHandler.vala 2013-12-14 19:29:24 +0000
18+++ src/Services/FileHandler.vala 2015-03-15 22:51:28 +0000
19@@ -35,10 +35,12 @@
20 var dis = new DataInputStream (file.read ());
21 string line = null;
22 while ((line = yield dis.read_line_async (Priority.DEFAULT)) != null) {
23+ if (text.len != 0)
24+ text.append_c ('\n');
25+
26 text.append (line);
27- text.append_c ('\n');
28 }
29- return text.erase(text.len - 1, 1).str;
30+ return text.str;
31 } catch (Error e) {
32 warning ("Cannot read \"%s\": %s", file.get_basename (), e.message);
33 return null;
34@@ -53,11 +55,13 @@
35 string line = null;
36 while ((line = dis.read_line (null, null)) != null) {
37 if (line != "\n") {
38+ if (text.len != 0)
39+ text.append_c ('\n');
40+
41 text.append (line);
42- text.append_c ('\n');
43 }
44 }
45- return text.erase(text.len - 1, 1).str;
46+ return text.str;
47 } catch (Error e) {
48 warning ("Cannot read \"%s\": %s", file.get_basename (), e.message);
49 return null;

Subscribers

People subscribed via source and target branches