Fixed bug in saving files: was missing os.O_TRUNC bit flag
This commit is contained in:
parent
9133ab55d0
commit
d47e407063
4
main.go
4
main.go
@ -129,7 +129,7 @@ func main() {
|
||||
tab := tabContainer.GetTab(tabContainer.GetSelectedTabIdx())
|
||||
te := tab.Child.(*ui.TextEdit)
|
||||
if len(te.FilePath) > 0 {
|
||||
f, err := os.OpenFile(te.FilePath, os.O_WRONLY|os.O_CREATE, fs.ModePerm)
|
||||
f, err := os.OpenFile(te.FilePath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, fs.ModePerm)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@ -312,7 +312,7 @@ func main() {
|
||||
s.Sync() // Redraw everything
|
||||
case *tcell.EventKey:
|
||||
// On Escape, we change focus between editor and the MenuBar.
|
||||
if dialog == nil { // While no dialog is present...
|
||||
if dialog == nil {
|
||||
if ev.Key() == tcell.KeyEscape {
|
||||
if focusedComponent == tabContainer {
|
||||
changeFocus(menuBar)
|
||||
|
@ -16,17 +16,6 @@ func TestRopeInserting(t *testing.T) {
|
||||
t.Errorf("string does not match \"withtext\", got %#v", str)
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
//withtext
|
||||
//
|
||||
|
||||
// Note the inclusive bounds and pointing to last line, first column.
|
||||
buf.Remove(0, 0, 1, 0) // Delete all of the buffer
|
||||
|
||||
if str := string(buf.Bytes()); str != "" {
|
||||
t.Errorf("string does not math \"\", got %#v", str)
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
|
||||
func TestRopeBounds(t *testing.T) {
|
||||
|
@ -113,7 +113,6 @@ func (t *TextEdit) Delete(forwards bool) {
|
||||
t.Dirty = true
|
||||
|
||||
if t.selectMode { // If text is selected, delete the whole selection
|
||||
t.cury, t.curx = t.Buffer.ClampLineCol(t.selection.EndLine, t.selection.EndCol)
|
||||
t.selectMode = false // Disable selection and prevent infinite loop
|
||||
|
||||
// Delete the region
|
||||
|
Loading…
x
Reference in New Issue
Block a user