Skip to content

Commit 129206a

Browse files
committed
feat: enhance clipboard handling and paste detection with user feedback
1 parent 664bb64 commit 129206a

10 files changed

Lines changed: 256 additions & 313 deletions

File tree

source/hooks/input/useClipboard.ts

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -162,35 +162,31 @@ end try'`;
162162
}
163163

164164
// If no image, try to read text from clipboard
165-
try {
166-
let clipboardText = '';
167-
if (process.platform === 'win32') {
168-
clipboardText = execSync('powershell -Command "Get-Clipboard"', {
169-
encoding: 'utf-8',
170-
timeout: 2000,
171-
}).trim();
172-
} else if (process.platform === 'darwin') {
173-
clipboardText = execSync('pbpaste', {
174-
encoding: 'utf-8',
175-
timeout: 2000,
176-
}).trim();
177-
} else {
178-
clipboardText = execSync('xclip -selection clipboard -o', {
179-
encoding: 'utf-8',
180-
timeout: 2000,
181-
}).trim();
182-
}
165+
let clipboardText = '';
166+
if (process.platform === 'win32') {
167+
clipboardText = execSync('powershell -Command "Get-Clipboard"', {
168+
encoding: 'utf-8',
169+
timeout: 2000,
170+
}).trim();
171+
} else if (process.platform === 'darwin') {
172+
clipboardText = execSync('pbpaste', {
173+
encoding: 'utf-8',
174+
timeout: 2000,
175+
}).trim();
176+
} else {
177+
clipboardText = execSync('xclip -selection clipboard -o', {
178+
encoding: 'utf-8',
179+
timeout: 2000,
180+
}).trim();
181+
}
183182

184-
if (clipboardText) {
185-
buffer.insert(clipboardText);
186-
const fullText = buffer.getFullText();
187-
const cursorPos = buffer.getCursorPosition();
188-
updateCommandPanelState(fullText);
189-
updateFilePickerState(fullText, cursorPos);
190-
triggerUpdate();
191-
}
192-
} catch (textError) {
193-
logger.error('Failed to read text from clipboard:', textError);
183+
if (clipboardText) {
184+
buffer.insert(clipboardText);
185+
const fullText = buffer.getFullText();
186+
const cursorPos = buffer.getCursorPosition();
187+
updateCommandPanelState(fullText);
188+
updateFilePickerState(fullText, cursorPos);
189+
triggerUpdate();
194190
}
195191
} catch (error) {
196192
logger.error('Failed to read from clipboard:', error);

0 commit comments

Comments
 (0)