fix: clip list width edge cases (falsy check, narrow-window clamp)
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -95,7 +95,8 @@
|
||||
if (!isSidebarResizing) return;
|
||||
const delta = e.clientX - sidebarResizeStartX;
|
||||
const maxWidth = Math.round(windowWidth * 0.4);
|
||||
const newWidth = Math.max(150, Math.min(maxWidth, sidebarResizeStartWidth + delta));
|
||||
const minWidth = Math.min(150, maxWidth);
|
||||
const newWidth = Math.max(minWidth, Math.min(maxWidth, sidebarResizeStartWidth + delta));
|
||||
preferences.clipListWidth = newWidth;
|
||||
}
|
||||
|
||||
@@ -289,14 +290,18 @@
|
||||
tabindex="0"
|
||||
onmousedown={handleSidebarResizeStart}
|
||||
onkeydown={(e) => {
|
||||
const maxWidth = Math.round(windowWidth * 0.4);
|
||||
const minWidth = Math.min(150, maxWidth);
|
||||
if (e.key === 'ArrowRight') {
|
||||
e.preventDefault();
|
||||
setClipListWidth(
|
||||
Math.min(Math.round(windowWidth * 0.4), preferences.clipListWidth + 10),
|
||||
Math.max(minWidth, Math.min(maxWidth, preferences.clipListWidth + 10)),
|
||||
);
|
||||
} else if (e.key === 'ArrowLeft') {
|
||||
e.preventDefault();
|
||||
setClipListWidth(Math.max(150, preferences.clipListWidth - 10));
|
||||
setClipListWidth(
|
||||
Math.max(minWidth, Math.min(maxWidth, preferences.clipListWidth - 10)),
|
||||
);
|
||||
}
|
||||
}}
|
||||
></div>
|
||||
|
||||
@@ -80,7 +80,7 @@ export async function loadPreferences(): Promise<void> {
|
||||
const savedClipListPosition = await store.get<'bottom' | 'left'>('clipListPosition');
|
||||
const savedClipListWidth = await store.get<number>('clipListWidth');
|
||||
if (savedClipListPosition) preferences.clipListPosition = savedClipListPosition;
|
||||
if (savedClipListWidth) preferences.clipListWidth = savedClipListWidth;
|
||||
if (savedClipListWidth != null) preferences.clipListWidth = savedClipListWidth;
|
||||
})();
|
||||
await loadPromise;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user