Force a UTF-8 ctype, stable buffer ids, redraw after deferred opens
- main: when the environment's locale is not UTF-8 (LANG unset, C/POSIX), switch LC_CTYPE to a UTF-8 locale so ncurses delivers and draws multibyte characters instead of dropping them. - Buffer::Id(): a process-unique id that survives moves and is fresh for copies. The terminal renderer's skip and cursor caches and the reload confirmation now key on it rather than the buffer's address, which is reused after a buffer is closed. - The reload confirmation is cancelled by any other command, like the quit confirmation. - TerminalFrontend redraws when a deferred open starts a prompt or sets a status (e.g. the swap recovery question), not only when a buffer opens. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015rcVQiiWyTzoNrsvLSaAfB
This commit is contained in:
@@ -34,6 +34,7 @@
|
||||
* - Direct PieceTable access for new editing operations
|
||||
*/
|
||||
#pragma once
|
||||
#include <atomic>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
@@ -352,6 +353,15 @@ public:
|
||||
}
|
||||
|
||||
|
||||
// Identity of this document, stable for its lifetime, including when the
|
||||
// Buffer object is moved (e.g. by the editor's buffer vector). Copies get
|
||||
// a new id. Use it, not the object's address, to key per-buffer caches.
|
||||
[[nodiscard]] std::uint64_t Id() const
|
||||
{
|
||||
return id_;
|
||||
}
|
||||
|
||||
|
||||
[[nodiscard]] bool Dirty() const
|
||||
{
|
||||
return dirty_;
|
||||
@@ -703,6 +713,13 @@ private:
|
||||
std::string filename_;
|
||||
bool is_file_backed_ = false;
|
||||
bool is_virtual_ = false;
|
||||
std::uint64_t id_ = NextBufferId();
|
||||
|
||||
static std::uint64_t NextBufferId()
|
||||
{
|
||||
static std::atomic<std::uint64_t> next{1};
|
||||
return next.fetch_add(1);
|
||||
}
|
||||
bool dirty_ = false;
|
||||
bool read_only_ = false;
|
||||
bool mark_set_ = false;
|
||||
|
||||
Reference in New Issue
Block a user