core: selection and copy bindings need to hold the big lock (#9818)
This was found by LLM hunting! We were not holding the lock properly during these operations. There aren't any known cases where we can directly attribute these races to issues but we did find at least one consistent crash for a user when `linkAtPos` wasn't properly locked (in another PR). This continues those fixes. https://ampcode.com/threads/T-6fc49f25-7f2f-4039-adb4-f86aaeced6d5pull/9819/head
commit
e5def6f210
|
|
@ -5032,8 +5032,9 @@ pub fn performBindingAction(self: *Surface, action: input.Binding.Action) !bool
|
|||
},
|
||||
|
||||
.copy_to_clipboard => |format| {
|
||||
// We can read from the renderer state without holding
|
||||
// the lock because only we will write to this field.
|
||||
self.renderer_state.mutex.lock();
|
||||
defer self.renderer_state.mutex.unlock();
|
||||
|
||||
if (self.io.terminal.screens.active.selection) |sel| {
|
||||
try self.copySelectionToClipboards(
|
||||
sel,
|
||||
|
|
@ -5061,8 +5062,10 @@ pub fn performBindingAction(self: *Surface, action: input.Binding.Action) !bool
|
|||
.copy_url_to_clipboard => {
|
||||
// If the mouse isn't over a link, nothing we can do.
|
||||
if (!self.mouse.over_link) return false;
|
||||
|
||||
const pos = try self.rt_surface.getCursorPos();
|
||||
|
||||
self.renderer_state.mutex.lock();
|
||||
defer self.renderer_state.mutex.unlock();
|
||||
if (try self.linkAtPos(pos)) |link_info| {
|
||||
const url_text = switch (link_info[0]) {
|
||||
.open => url_text: {
|
||||
|
|
@ -5438,6 +5441,9 @@ pub fn performBindingAction(self: *Surface, action: input.Binding.Action) !bool
|
|||
),
|
||||
|
||||
.select_all => {
|
||||
self.renderer_state.mutex.lock();
|
||||
defer self.renderer_state.mutex.unlock();
|
||||
|
||||
const sel = self.io.terminal.screens.active.selectAll();
|
||||
if (sel) |s| {
|
||||
try self.setSelection(s);
|
||||
|
|
|
|||
Loading…
Reference in New Issue