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

@@ -620,6 +620,16 @@ func (b *Buffer) WordAt(loc Loc) []byte {
return b.Substr(start, end)
}
// Shared returns if there are other buffers with the same file as this buffer
func (b *Buffer) Shared() bool {
for _, buf := range OpenBuffers {
if buf != b && buf.SharedBuffer == b.SharedBuffer {
return true
}
}
return false
}
// Modified returns if this buffer has been modified since
// being opened
func (b *Buffer) Modified() bool {