@matheusbsbs / matheus-bagliano / commits / b2c6fcf197
Fork 0

git-gui: Clear undo/redo stack when loading a message file from disk.

If we load a message file (e.g. MERGE_MSG) or we have just finished making a commit and are clearing out the commit buffer we should also clear out the undo/redo stack associated with that buffer. The prior undo/redo stack has no associated with the new content and therefore is not useful to the user. Also modified the sign-off operation to perform the entire update in a single undo/redo operation, allowing the user to undo the signoff in case they didn't actually want to do that. I also noticed what may be a crash on Windows related to the up and down arrow keys navigating within the diff viewer. Since I got back no stack trace (just an application exit with a loss of the commit message) I suspect that the binding to scroll the text widget crashed with an error and the wish process just terminated. So now we catch (and ignore) any sort of error related to the arrow keys in the diff viewer. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Shawn O. Pearce committed Nov 11, 2006 at 16:16 UTC b2c6fcf197fd09a6fedb39e4d8d13e6fdc2df4d4
1 file changed +11 -6
git-gui
+11 -6
@@ -179,6 +179,7 @@ proc update_status {{final Ready.}} {
179 } elseif {[load_message SQUASH_MSG]} {
180 }
181 $ui_comm edit modified false
182 + $ui_comm edit reset
183 }
184
185 if {$cfg_trust_mtime == {true}} {
@@ -503,6 +504,7 @@ proc load_last_commit {} {
504 $ui_comm delete 0.0 end
505 $ui_comm insert end $msg
506 $ui_comm edit modified false
507 + $ui_comm edit reset
508 update_status
509 } else {
510 error_popup {You can't amend a merge commit.}
@@ -698,6 +700,7 @@ proc commit_stage2 {fd_wt curHEAD msg} {
700
701 $ui_comm delete 0.0 end
702 $ui_comm edit modified false
703 + $ui_comm edit reset
704
705 if {$single_commit} do_quit
706
@@ -1463,8 +1466,9 @@ proc do_signoff {} {
1466
1467 set str "Signed-off-by: $GIT_COMMITTER_IDENT"
1468 if {[$ui_comm get {end -1c linestart} {end -1c}] != $str} {
1466 - $ui_comm insert end "\n"
1467 - $ui_comm insert end $str
1469 + $ui_comm edit separator
1470 + $ui_comm insert end "\n$str"
1471 + $ui_comm edit separator
1472 $ui_comm see end
1473 }
1474 }
@@ -1733,6 +1737,7 @@ trace add variable commit_type write {uplevel #0 {
1737 }}
1738 text $ui_comm -background white -borderwidth 1 \
1739 -undo true \
1740 + -maxundo 20 \
1741 -autoseparators true \
1742 -relief sunken \
1743 -width 75 -height 9 -wrap none \
@@ -1836,10 +1841,10 @@ bind $ui_diff <$M1B-Key-v> {break}
1841 bind $ui_diff <$M1B-Key-V> {break}
1842 bind $ui_diff <$M1B-Key-a> {%W tag add sel 0.0 end;break}
1843 bind $ui_diff <$M1B-Key-A> {%W tag add sel 0.0 end;break}
1839 -bind $ui_diff <Key-Up> {%W yview scroll -1 units}
1840 -bind $ui_diff <Key-Down> {%W yview scroll 1 units}
1841 -bind $ui_diff <Key-Left> {%W xview scroll -1 units}
1842 -bind $ui_diff <Key-Right> {%W xview scroll 1 units}
1844 +bind $ui_diff <Key-Up> {catch {%W yview scroll -1 units};break}
1845 +bind $ui_diff <Key-Down> {catch {%W yview scroll 1 units};break}
1846 +bind $ui_diff <Key-Left> {catch {%W xview scroll -1 units};break}
1847 +bind $ui_diff <Key-Right> {catch {%W xview scroll 1 units};break}
1848
1849 bind . <Destroy> do_quit
1850 bind all <Key-F5> do_rescan