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;
|
if (!isSidebarResizing) return;
|
||||||
const delta = e.clientX - sidebarResizeStartX;
|
const delta = e.clientX - sidebarResizeStartX;
|
||||||
const maxWidth = Math.round(windowWidth * 0.4);
|
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;
|
preferences.clipListWidth = newWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -289,14 +290,18 @@
|
|||||||
tabindex="0"
|
tabindex="0"
|
||||||
onmousedown={handleSidebarResizeStart}
|
onmousedown={handleSidebarResizeStart}
|
||||||
onkeydown={(e) => {
|
onkeydown={(e) => {
|
||||||
|
const maxWidth = Math.round(windowWidth * 0.4);
|
||||||
|
const minWidth = Math.min(150, maxWidth);
|
||||||
if (e.key === 'ArrowRight') {
|
if (e.key === 'ArrowRight') {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
setClipListWidth(
|
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') {
|
} else if (e.key === 'ArrowLeft') {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
setClipListWidth(Math.max(150, preferences.clipListWidth - 10));
|
setClipListWidth(
|
||||||
|
Math.max(minWidth, Math.min(maxWidth, preferences.clipListWidth - 10)),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
></div>
|
></div>
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ export async function loadPreferences(): Promise<void> {
|
|||||||
const savedClipListPosition = await store.get<'bottom' | 'left'>('clipListPosition');
|
const savedClipListPosition = await store.get<'bottom' | 'left'>('clipListPosition');
|
||||||
const savedClipListWidth = await store.get<number>('clipListWidth');
|
const savedClipListWidth = await store.get<number>('clipListWidth');
|
||||||
if (savedClipListPosition) preferences.clipListPosition = savedClipListPosition;
|
if (savedClipListPosition) preferences.clipListPosition = savedClipListPosition;
|
||||||
if (savedClipListWidth) preferences.clipListWidth = savedClipListWidth;
|
if (savedClipListWidth != null) preferences.clipListWidth = savedClipListWidth;
|
||||||
})();
|
})();
|
||||||
await loadPromise;
|
await loadPromise;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user