Skip to content

Commit e2b3719

Browse files
committed
TSQL don't comment lines last line if the cursor is at the beginning
Removed unused scopes from shortcuts
1 parent e622d1b commit e2b3719

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

apps/webapp/app/components/code/TSQLEditor.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@ const defaultProps: TSQLEditorDefaultProps = {
6464
const toggleLineComment = (view: EditorView): boolean => {
6565
const { from, to } = view.state.selection.main;
6666
const startLine = view.state.doc.lineAt(from);
67-
const endLine = view.state.doc.lineAt(to);
67+
// When `to` is exactly at the start of a line and there's an actual selection,
68+
// the caret sits before that line — so exclude it by stepping back one position.
69+
const adjustedTo = to > from && view.state.doc.lineAt(to).from === to ? to - 1 : to;
70+
const endLine = view.state.doc.lineAt(adjustedTo);
6871

6972
// Collect all lines in the selection
7073
const lines: { from: number; to: number; text: string }[] = [];

apps/webapp/app/hooks/useShortcutKeys.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,13 @@ type useShortcutKeysProps = {
2323
action: (event: KeyboardEvent) => void;
2424
disabled?: boolean;
2525
enabledOnInputElements?: boolean;
26-
scopes?: string | string[];
2726
};
2827

2928
export function useShortcutKeys({
3029
shortcut,
3130
action,
3231
disabled = false,
3332
enabledOnInputElements,
34-
scopes = "global",
3533
}: useShortcutKeysProps) {
3634
const { platform } = useOperatingSystem();
3735
const { areShortcutsEnabled } = useShortcuts();
@@ -52,7 +50,6 @@ export function useShortcutKeys({
5250
},
5351
{
5452
enabled: isEnabled,
55-
scopes,
5653
enableOnFormTags:
5754
isEnabled && (enabledOnInputElements ?? relevantShortcut?.enabledOnInputElements),
5855
enableOnContentEditable:

apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.logs/route.tsx

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -402,24 +402,25 @@ function LogsList({
402402
return;
403403
}
404404

405-
const existingIds = new Set(accumulatedLogs.map((log) => log.id));
406-
const newLogs = fetcher.data.logs.filter((log) => !existingIds.has(log.id));
407-
408405
if (isCheckingForNewRef.current) {
409406
// "Check for new" - prepend new logs, don't update cursor
410-
if (newLogs.length > 0) {
411-
setAccumulatedLogs((prev) => [...newLogs, ...prev]);
412-
}
407+
setAccumulatedLogs((prev) => {
408+
const existingIds = new Set(prev.map((log) => log.id));
409+
const newLogs = fetcher.data!.logs.filter((log) => !existingIds.has(log.id));
410+
return newLogs.length > 0 ? [...newLogs, ...prev] : prev;
411+
});
413412
isCheckingForNewRef.current = false;
414413
} else {
415414
// "Load more" - append logs and update cursor
416-
if (newLogs.length > 0) {
417-
setAccumulatedLogs((prev) => [...prev, ...newLogs]);
418-
}
415+
setAccumulatedLogs((prev) => {
416+
const existingIds = new Set(prev.map((log) => log.id));
417+
const newLogs = fetcher.data!.logs.filter((log) => !existingIds.has(log.id));
418+
return newLogs.length > 0 ? [...prev, ...newLogs] : prev;
419+
});
419420
setNextCursor(fetcher.data.pagination.next);
420421
}
421422
}
422-
}, [fetcher.data, fetcher.state, accumulatedLogs, location.search]);
423+
}, [fetcher.data, fetcher.state, location.search]);
423424

424425
// Build resource URL for loading more
425426
const loadMoreUrl = useMemo(() => {

apps/webapp/app/routes/resources.orgs.$organizationSlug.projects.$projectParam.env.$envParam.logs.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { LogsListPresenter, type LogLevel, LogsListOptionsSchema } from "~/prese
88
import { $replica } from "~/db.server";
99
import { clickhouseClient } from "~/services/clickhouseInstance.server";
1010
import { getCurrentPlan } from "~/services/platform.v3.server";
11-
import { getTimezonePreference } from "~/services/preferences/uiPreferences.server";
1211

1312
// Valid log levels for filtering
1413
const validLevels: LogLevel[] = ["DEBUG", "INFO", "WARN", "ERROR"];

0 commit comments

Comments
 (0)