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

Proposed by Corentin Noël
Status: Merged
Approved by: Corentin Noël
Approved revision: 1512
Merged at revision: 1516
Proposed branch: lp:~tintou/scratch/fix-save
Merge into: lp:~elementary-apps/scratch/scratch
Diff against target: 58 lines (+5/-12)
2 files modified
src/Services/Document.vala (+1/-1)
src/Widgets/SearchManager.vala (+4/-11)
To merge this branch: bzr merge lp:~tintou/scratch/fix-save
Reviewer Review Type Date Requested Status
Robert Roth (community) Approve
Gero.Bare (community) Abstain
Review via email: mp+259702@code.launchpad.net

Commit message

Prevent Scratch from reload a currently open file from disk before it has the opportunity to save it.

Description of the change

Fixed a bug making Scratch load the content of the file in the disk when the current view is not even saved…

To post a comment you must log in.
Revision history for this message
Gero.Bare (gero-bare) wrote :

Nice. This works pretty well.

review: Approve
Revision history for this message
Gero.Bare (gero-bare) wrote :

Ok I think I should correct my previous statement.
This is a huge improvement, yet I found a little bug.

For example you have a bunch of "do" skips some, replace for "don't" then replace all, then sometimes a "empty file" appears in the undo history.

But I didn't see a loss of data though. So it's a huge improvement.

But for now I think I should abstain and let other judge this.

But this branch seems to work fine otherwise.

review: Abstain
Revision history for this message
Robert Roth (evfool) wrote :

All the changes make sense, and as gero-bare mentions the data-loss issue is gone, I think we should approve this.
As of gero-bare's comment giving an example for an incorrect use-case: that looks like a corner-case, which is unlikely to be related to the code changes done here, but has surfaced due to the critical issue being gone, that should be handled in a separate bugreport.

review: Approve

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-05-10 07:10:54 +0000
3+++ src/Services/Document.vala 2015-05-20 22:10:15 +0000
4@@ -582,7 +582,7 @@
5 return;
6 }
7
8- if (source_view.buffer.get_modified ()) {
9+ if (!source_view.buffer.get_modified ()) {
10 if (settings.autosave) {
11 source_view.set_text (new_buffer.text, false);
12 } else {
13
14=== modified file 'src/Widgets/SearchManager.vala'
15--- src/Widgets/SearchManager.vala 2015-05-15 08:16:47 +0000
16+++ src/Widgets/SearchManager.vala 2015-05-20 22:10:15 +0000
17@@ -36,7 +36,7 @@
18 public Gtk.SearchEntry replace_entry;
19 public Gtk.SpinButton go_to_entry;
20 private Gtk.Adjustment go_to_adj;
21-
22+
23 private Gtk.ToolButton replace_tool_button;
24 private Gtk.ToolButton replace_all_tool_button;
25
26@@ -163,10 +163,10 @@
27 warning ("No SourceView is associated with SearchManager!");
28 return;
29 }
30-
31+
32 if (this.text_view != null)
33 this.text_buffer.modified_changed.disconnect (on_text_buffer_modified);
34-
35+
36 this.text_view = text_view;
37 this.text_buffer = text_view.get_buffer ();
38 this.search_context = new Gtk.SourceSearchContext (text_buffer as Gtk.SourceBuffer, null);
39@@ -222,18 +222,11 @@
40 return;
41 }
42 string replace_string = replace_entry.text;
43- // temporarily disable all textbuffer changed signal handlers
44- this.text_buffer.modified_changed.disconnect (on_text_buffer_modified);
45 this.window.get_current_document ().toggle_changed_handlers (false);
46- var replaced = search_context.replace_all (replace_string, replace_string.length);
47+ search_context.replace_all (replace_string, replace_string.length);
48 update_tool_arrows (search_entry.text);
49 update_replace_tool_sensitivities (search_entry.text, false);
50- // reenable all disabled buffer changed signal handlers
51- this.text_buffer.modified_changed.connect (on_text_buffer_modified);
52 this.window.get_current_document ().toggle_changed_handlers (true);
53- // notify the buffer of the change after replace all
54- if (replaced > 0)
55- this.text_buffer.modified_changed ();
56 }
57
58 public void set_search_string (string to_search) {

Subscribers

People subscribed via source and target branches