mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 08:46:08 +03:00
terminal: test hyperlink reuse shares ID
This commit is contained in:
@ -1381,8 +1381,6 @@ pub fn startHyperlink(
|
|||||||
const link = try Hyperlink.create(self.alloc, uri, id_);
|
const link = try Hyperlink.create(self.alloc, uri, id_);
|
||||||
errdefer link.destroy(self.alloc);
|
errdefer link.destroy(self.alloc);
|
||||||
|
|
||||||
// TODO: look for previous hyperlink that matches this.
|
|
||||||
|
|
||||||
// Copy our URI into the page memory.
|
// Copy our URI into the page memory.
|
||||||
var page = &self.cursor.page_pin.page.data;
|
var page = &self.cursor.page_pin.page.data;
|
||||||
const string_alloc = &page.string_alloc;
|
const string_alloc = &page.string_alloc;
|
||||||
@ -7439,6 +7437,40 @@ test "Screen: hyperlink start/end" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test "Screen: hyperlink reuse" {
|
||||||
|
const testing = std.testing;
|
||||||
|
const alloc = testing.allocator;
|
||||||
|
|
||||||
|
var s = try init(alloc, 5, 5, 0);
|
||||||
|
defer s.deinit();
|
||||||
|
|
||||||
|
try testing.expect(s.cursor.hyperlink_id == 0);
|
||||||
|
{
|
||||||
|
const page = &s.cursor.page_pin.page.data;
|
||||||
|
try testing.expectEqual(0, page.hyperlink_set.count());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use it for the first time
|
||||||
|
try s.startHyperlink("http://example.com", null);
|
||||||
|
try testing.expect(s.cursor.hyperlink_id != 0);
|
||||||
|
const id = s.cursor.hyperlink_id;
|
||||||
|
|
||||||
|
// Reuse the same hyperlink, expect we have the same ID
|
||||||
|
try s.startHyperlink("http://example.com", null);
|
||||||
|
try testing.expectEqual(id, s.cursor.hyperlink_id);
|
||||||
|
{
|
||||||
|
const page = &s.cursor.page_pin.page.data;
|
||||||
|
try testing.expectEqual(1, page.hyperlink_set.count());
|
||||||
|
}
|
||||||
|
|
||||||
|
s.endHyperlink();
|
||||||
|
try testing.expect(s.cursor.hyperlink_id == 0);
|
||||||
|
{
|
||||||
|
const page = &s.cursor.page_pin.page.data;
|
||||||
|
try testing.expectEqual(0, page.hyperlink_set.count());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
test "Screen: adjustCapacity cursor style ref count" {
|
test "Screen: adjustCapacity cursor style ref count" {
|
||||||
const testing = std.testing;
|
const testing = std.testing;
|
||||||
const alloc = testing.allocator;
|
const alloc = testing.allocator;
|
||||||
|
Reference in New Issue
Block a user