Skip save on open or term command if buffer is shared

This commit is contained in:
niten94
2025-04-18 19:19:19 +08:00
parent 79fe4ae3e3
commit 0d5b2b73e3
3 changed files with 13 additions and 10 deletions

View File

@@ -1909,14 +1909,7 @@ func (h *BufPane) ForceQuit() bool {
// Quit this will close the current tab or view that is open
func (h *BufPane) Quit() bool {
if h.Buf.Modified() {
for _, b := range buffer.OpenBuffers {
if b != h.Buf && b.SharedBuffer == h.Buf.SharedBuffer {
h.ForceQuit()
return true
}
}
if h.Buf.Modified() && !h.Buf.Shared() {
if config.GlobalSettings["autosave"].(float64) > 0 && h.Buf.Path != "" {
// autosave on means we automatically save when quitting
h.SaveCB("Quit", func() {

View File

@@ -308,7 +308,7 @@ func (h *BufPane) OpenCmd(args []string) {
}
h.OpenBuffer(b)
}
if h.Buf.Modified() {
if h.Buf.Modified() && !h.Buf.Shared() {
InfoBar.YNPrompt("Save changes to "+h.Buf.GetName()+" before closing? (y,n,esc)", func(yes, canceled bool) {
if !canceled && !yes {
open()
@@ -1121,7 +1121,7 @@ func (h *BufPane) TermCmd(args []string) {
for i, p := range ps {
if p.ID() == h.ID() {
if h.Buf.Modified() {
if h.Buf.Modified() && !h.Buf.Shared() {
InfoBar.YNPrompt("Save changes to "+h.Buf.GetName()+" before closing? (y,n,esc)", func(yes, canceled bool) {
if !canceled && !yes {
term(i, false)