Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ resolver = "2"
members = ["crates/openpl-oracle", "crates/openpl-core", "app/src-tauri"]

[workspace.package]
version = "1.0.0-beta.14"
version = "1.0.0-beta.15"
edition = "2021"
license = "Apache-2.0 OR MIT"

Expand Down
4 changes: 2 additions & 2 deletions app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "openpl",
"private": true,
"version": "1.0.0-beta.14",
"version": "1.0.0-beta.15",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
2 changes: 1 addition & 1 deletion app/src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://schema.tauri.app/config/2",
"productName": "OpenPL",
"version": "1.0.0-beta.14",
"version": "1.0.0-beta.15",
"identifier": "org.openpl.app",
"build": {
"beforeDevCommand": "npm run dev",
Expand Down
46 changes: 46 additions & 0 deletions app/src/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1567,3 +1567,49 @@ test("clic derecho en una pestaña cierra varias ventanas y deja las de transacc
await waitFor(() => expect(tabs.queryByRole("button", { name: /^Programa/ })).not.toBeInTheDocument());
expect(tabs.getByRole("button", { name: /^SQL 1/ })).toBeInTheDocument();
});

test("una ventana SQL nueva o reactivada deja el foco en el editor", async () => {
windowEvents.close.mockResolvedValue(() => {});
vi.mocked(api.listObjects).mockResolvedValue([]);
vi.mocked(api.sqlOpen).mockResolvedValueOnce("w1").mockResolvedValueOnce("w2");
render(<App />);
await connectAs();
fireEvent.keyDown(window, { key: "n", ctrlKey: true });
const first = await screen.findByRole("textbox", { name: "SQL" });
await waitFor(() => expect(first).toHaveFocus());
fireEvent.keyDown(window, { key: "n", ctrlKey: true });
const tabs = within(screen.getByLabelText("Programas abiertos"));
await tabs.findByRole("button", { name: /^SQL 2/ });
await waitFor(() => expect(first).not.toHaveFocus());
const tab = tabs.getByRole("button", { name: /^SQL 1/ });
tab.focus();
fireEvent.click(tab);
await waitFor(() => expect(first).toHaveFocus());
});

test("Ctrl A fuera del editor selecciona el texto de la ventana activa y no la interfaz", async () => {
windowEvents.close.mockResolvedValue(() => {});
vi.mocked(api.listObjects).mockResolvedValue([]);
vi.mocked(api.sqlOpen).mockResolvedValueOnce("w1");
render(<App />);
await connectAs();
fireEvent.keyDown(window, { key: "n", ctrlKey: true });
const editor = await screen.findByRole("textbox", { name: "SQL" });
const view = EditorView.findFromDOM(editor.closest<HTMLElement>(".cm-editor")!)!;
act(() => view.dispatch({ changes: { from: 0, insert: "select 1 from dual" } }));
const tab = within(screen.getByLabelText("Programas abiertos")).getByRole("button", { name: /^SQL 1/ });
tab.focus();
let handled = false;
act(() => { handled = press(tab, { key: "a", ctrlKey: true }); });
expect(handled).toBe(true);
expect(editor).toHaveFocus();
expect(view.state.selection.main).toMatchObject({ from: 0, to: 18 });
});

test("Ctrl A en un campo de texto conserva la selección nativa", async () => {
windowEvents.close.mockResolvedValue(() => {});
render(<App />);
const input = (await screen.findAllByRole("textbox"))[0];
input.focus();
expect(press(input, { key: "a", ctrlKey: true })).toBe(false);
});
14 changes: 14 additions & 0 deletions app/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ import { neighbor, reorder } from "./tabs";
import { captureWorkspace, validateWorkspace } from "./workspace";
import { Logo } from "./components/Logo";
import { ContextMenu, type ContextItem } from "./components/ContextMenu";
import { EditorView } from "@codemirror/view";
import { selectAll } from "@codemirror/commands";
import { closeNotice, closeScopes, discardMessage, planClose } from "./closeTabs";
import { CommandPalette } from "./components/CommandPalette";
import { routineDraft, type RoutineOverload } from "./routineTest";
Expand Down Expand Up @@ -397,6 +399,18 @@ export default function App() {
isFieldKey(e)
)
return;
// Ctrl+A fuera de un campo seleccionaría toda la interfaz: va al editor de la pestaña activa.
if (matches(e, "Ctrl+A") && !(target instanceof HTMLElement && target.closest("input, textarea, [contenteditable=\"true\"], .cm-editor"))) {
e.preventDefault();
const editor = [...document.querySelectorAll<HTMLElement>(".program-document .cm-editor")]
.find((element) => !element.closest("[hidden]"));
const view = editor && EditorView.findFromDOM(editor);
if (view) {
view.focus();
selectAll(view);
}
return;
}
handleShortcut(e, actions);
};
window.addEventListener("keydown", onKey);
Expand Down
15 changes: 14 additions & 1 deletion app/src/components/SqlWindow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1004,6 +1004,19 @@ export function SqlWindow({
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

// Al abrir o volver a la pestaña el foco va al editor, salvo que ya esté dentro de la ventana o haya un diálogo.
const root = useRef<HTMLElement>(null);
const wasActive = useRef(false);
useEffect(() => {
const activated = active && !wasActive.current;
wasActive.current = active;
if (!activated || command) return;
const focused = document.activeElement;
if (focused && root.current?.contains(focused)) return;
if (document.querySelector('[aria-modal="true"], dialog[open]')) return;
view.current?.focus();
}, [active, command]);

const offset = grid?.hiddenRowid ? 1 : 0;
const insertSource = activeQuery?.sql;
const insertTarget = useMemo(() => insertSource ? editableQuery(insertSource)?.table : undefined, [insertSource]);
Expand Down Expand Up @@ -1067,7 +1080,7 @@ export function SqlWindow({
{confirmationDialog}</>;

return (
<section className="sql-window" aria-label="Ventana SQL">
<section ref={root} className="sql-window" aria-label="Ventana SQL">
<div className="program-toolbar">
<button className="btn primary" onClick={actions.execute} disabled={running || fetching || applying}>
<Play size={14} aria-hidden /> Ejecutar <span className="kbd">{key("execute")}</span>
Expand Down
2 changes: 2 additions & 0 deletions docs/ESTADO.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

## Resumen

- WAL-131: al abrir una ventana SQL o volver a su pestaña, el foco queda en el editor sin hacer clic. Ctrl A fuera de un campo de texto o de la grilla selecciona el texto del editor activo en vez de la interfaz.

- GitHub #19: clic derecho en una pestaña cierra varias ventanas a la vez (otras, SQL, programas o todas) y **Archivo > Cerrar todas** cierra todo. Las ventanas SQL con transacción abierta quedan abiertas con un aviso. [Comportamiento](behavior/programa.md).

- WAL-128 y WAL-129 (GitHub #17 y #16): F8 sin selección ejecuta todas las sentencias y Ctrl+Enter solo la del cursor; cada SELECT abre su pestaña de resultado con su propio cursor (hasta 20 por sesión). El panel Estructura ofrece Copiar código y Comentar/Descomentar en cualquier entrada. [Diseño](superpowers/specs/2026-11-30-openpl-ejecutar-todo-y-pestanas-design.md).
Expand Down
2 changes: 1 addition & 1 deletion docs/behavior/sql.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Observación previa por uso normal: [observaciones-referencia.md](observaciones-referencia.md#ventana-sql-y-grilla).

- **Nueva ventana SQL** (Ctrl N o **Nuevo → Ventana SQL**) necesita una conexión activa. Abre una sesión propia con los mismos datos de la conexión: su transacción y su cancelación no afectan al explorador ni a otras ventanas. La pestaña muestra el color del entorno.
- **Nueva ventana SQL** (Ctrl N o **Nuevo → Ventana SQL**) necesita una conexión activa. Abre una sesión propia con los mismos datos de la conexión: su transacción y su cancelación no afectan al explorador ni a otras ventanas. La pestaña muestra el color del entorno. Al abrirla o volver a su pestaña, el cursor queda en el editor. Ctrl A fuera de un campo de texto o de la grilla selecciona el texto del editor activo, no la interfaz.
- **Ejecutar** (F8) ejecuta la selección o, sin selección, todas las sentencias en orden, y se detiene en el primer error. **Ejecutar sentencia** (Ctrl Enter) ejecuta solo la sentencia bajo el cursor; con el cursor en un comentario o en una línea vacía entre sentencias se ejecuta la siguiente, y después de la última no se ejecuta nada. **Ejecutar script** (Shift F8) sigue ejecutando todo.
- **Pestañas de resultado:** cada SELECT de la ejecución abre su pestaña, "Select tabla" (primera tabla del FROM, como está escrita) o "Consulta N". Queda activa la del último. Cada pestaña trae más filas, exporta, copia y edita por su cuenta; cambiar de pestaña con ediciones pendientes pide confirmar. Una ejecución nueva reemplaza las pestañas y cierra sus cursores. La sesión mantiene hasta 20 cursores abiertos; Rollback los cierra.
- Las sentencias se separan por `;` o por `/` en una línea sola. Un bloque PL/SQL (`DECLARE`, `BEGIN`, `CREATE PROCEDURE`, `FUNCTION`, `PACKAGE`, `TRIGGER`, `TYPE`) termina con `/` o, sin barra, cuando cierra su último `END`. Así el bloque no se lleva la sentencia que sigue. Los comentarios y literales, incluidos `q'[...]'`, no cuentan para esa cuenta.
Expand Down
Loading