forked from Shinonome/dots-hyprland
chatgpt: code snippet: fix buffer
This commit is contained in:
@@ -102,8 +102,8 @@ const CodeBlock = (content = '', lang = 'txt') => {
|
|||||||
]
|
]
|
||||||
}),
|
}),
|
||||||
onClicked: (self) => {
|
onClicked: (self) => {
|
||||||
const copyContent = sourceView.get_buffer().get_text(0, 0, 0); // TODO: fix this
|
const buffer = sourceView.get_buffer();
|
||||||
console.log(copyContent);
|
const copyContent = buffer.get_text(buffer.get_start_iter(), buffer.get_end_iter(), false); // TODO: fix this
|
||||||
execAsync([`wl-copy`, `${copyContent}`]).catch(print);
|
execAsync([`wl-copy`, `${copyContent}`]).catch(print);
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
@@ -164,7 +164,6 @@ const MessageContent = (content) => {
|
|||||||
// Code blocks
|
// Code blocks
|
||||||
const codeBlockRegex = /^\s*```([a-zA-Z0-9]+)?\n?/;
|
const codeBlockRegex = /^\s*```([a-zA-Z0-9]+)?\n?/;
|
||||||
if (codeBlockRegex.test(line)) {
|
if (codeBlockRegex.test(line)) {
|
||||||
// console.log(`code at line ${index}`);
|
|
||||||
const kids = self.get_children();
|
const kids = self.get_children();
|
||||||
const lastLabel = kids[kids.length - 1];
|
const lastLabel = kids[kids.length - 1];
|
||||||
const blockContent = lines.slice(lastProcessed, index).join('\n');
|
const blockContent = lines.slice(lastProcessed, index).join('\n');
|
||||||
|
|||||||
Reference in New Issue
Block a user