diff --git a/CHANGELOG.md b/CHANGELOG.md index 7acf92a..30f971e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 0.8.1 + +- Commit graph: dimming the commits outside the history of your HEAD is now off by default and remembered, with the + new setting `gitLore.graph.highlightCurrentBranch`. The target button in the toolbar still toggles it, and changes + the setting. +- Commit graph: the target button, when on, looks like VS Code's own toggles (the ones in the search box) instead of + a gray square. + ## 0.8.0 - Contributors chart: the chart icon in the Contributors view (or `Show Contributors Chart`) opens a bubble per diff --git a/README.md b/README.md index 6ed6aa7..e05bcd9 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ No account, no sign-in, no trial, no paywall, no telemetry. MIT licensed. ones tinted, tags neutral). Hover a message, author or badge for the full text. A row above HEAD shows your uncommitted changes. Choose all branches, local branches or the current branch, filter by message, author, ref or SHA, and scroll to load more. Drag the graph's edge to make it wider (double-click to reset). - With many branches, commits outside the history of your HEAD are dimmed (toggle it from the toolbar) and a floating + With many branches, the target button in the toolbar dims the commits outside the history of your HEAD and a floating button takes you back to your commit when it is out of view. - *Commit details:* click a commit (or press Enter; arrows move between rows) to open its message, author, parents and changed files inline. Each file opens its diff; right-click it to open it at that revision, compare it with the @@ -60,6 +60,7 @@ Everything is localized in English and Spanish. | Setting | Default | | |---|---|---| | `gitLore.currentLine.enabled` | `true` | Show the blame of the current line. Also `Git Lore: Toggle Current Line Blame`. | +| `gitLore.graph.highlightCurrentBranch` | `false` | In the commit graph, dim the commits that are not in the history of your HEAD. Also the target button in the graph toolbar. | The colors are themeable: `gitLore.currentLineForeground`, `gitLore.fileBlameForeground`, `gitLore.fileBlameBackground`. diff --git a/media/grafo.css b/media/grafo.css index a201104..c28d981 100644 --- a/media/grafo.css +++ b/media/grafo.css @@ -100,7 +100,12 @@ body { #fetch:active svg { transform: translateY(2px); } #fetch svg { transition: transform .2s var(--muelle); } .boton:disabled { opacity: .5; cursor: default; } -#resaltar[aria-pressed="true"] { color: var(--vscode-focusBorder); background: var(--vscode-toolbar-activeBackground, var(--vscode-toolbar-hoverBackground)); } +/* como los conmutadores del buscador de VS Code (Aa, .*): fondo y borde del tema, el icono se sigue leyendo */ +#resaltar[aria-pressed="true"] { + color: var(--vscode-inputOption-activeForeground, var(--vscode-icon-foreground)); + background: var(--vscode-inputOption-activeBackground, rgba(36, 137, 219, .51)); + box-shadow: inset 0 0 0 1px var(--vscode-inputOption-activeBorder, #2488db); +} /* lo que no es historia de HEAD queda en segundo plano; las líneas no, que son las que llevan a tu rama */ .fila > .texto, .fila > .autor, .fila > .fecha, .fila > .sha, .nodo { transition: opacity .2s ease-out; } diff --git a/media/grafo.js b/media/grafo.js index 7c97267..4604c54 100644 --- a/media/grafo.js +++ b/media/grafo.js @@ -19,7 +19,7 @@ const aqui = document.getElementById('aqui'); /** @type {{sha: string, nombre: string} | null} */ let actual = null; - let resaltar = (vscode.getState() || {}).resaltar !== false; + let resaltar = window.RESALTAR === true; let buscandoHead = 0; // páginas que quedan por pedir buscando la fila de HEAD let headInalcanzable = false; // se buscó y no está en este alcance: no se ofrece hasta la próxima recarga let filas = []; @@ -297,6 +297,11 @@ } window.addEventListener('message', ({ data: m }) => { + if (m.tipo === 'resaltar') { + resaltar = m.valor === true; + aplicarResaltado(); + return; + } if (m.tipo === 'error') { pidiendo = false; cargando(false); @@ -383,8 +388,8 @@ } botonResaltar.addEventListener('click', () => { resaltar = !resaltar; - vscode.setState({ ...(vscode.getState() || {}), resaltar }); aplicarResaltado(); + vscode.postMessage({ tipo: 'resaltar', valor: resaltar }); }); aplicarResaltado(); diff --git a/package-lock.json b/package-lock.json index fb99347..592109f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "git-lore", - "version": "0.8.0", + "version": "0.8.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "git-lore", - "version": "0.8.0", + "version": "0.8.1", "license": "MIT", "devDependencies": { "@vscode/vsce": "^4.1.1", diff --git a/package.json b/package.json index 6a26e12..1acbee1 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "git-lore", "displayName": "%displayName%", "description": "%description%", - "version": "0.8.0", + "version": "0.8.1", "publisher": "jlopez", "license": "MIT", "repository": { @@ -729,6 +729,11 @@ "type": "boolean", "default": true, "description": "%config.currentLine%" + }, + "gitLore.graph.highlightCurrentBranch": { + "type": "boolean", + "default": false, + "description": "%config.graphHighlight%" } } } diff --git a/package.nls.es.json b/package.nls.es.json index 9454211..d4d6acf 100644 --- a/package.nls.es.json +++ b/package.nls.es.json @@ -44,5 +44,6 @@ "command.previousRevision": "Abrir la revisión anterior", "command.nextRevision": "Abrir la revisión siguiente", "view.contributors": "Colaboradores", - "command.contributorsChart": "Ver gráfico de colaboradores" + "command.contributorsChart": "Ver gráfico de colaboradores", + "config.graphHighlight": "Grafo de commits: atenúa los commits que no están en la historia de la rama actual. El botón de la diana en la barra del grafo lo activa y desactiva." } diff --git a/package.nls.json b/package.nls.json index b597200..b424595 100644 --- a/package.nls.json +++ b/package.nls.json @@ -44,5 +44,6 @@ "command.previousRevision": "Open Previous Revision", "command.nextRevision": "Open Next Revision", "view.contributors": "Contributors", - "command.contributorsChart": "Show Contributors Chart" + "command.contributorsChart": "Show Contributors Chart", + "config.graphHighlight": "Commit Graph: dim the commits that are not in the history of the current branch. The target button in the graph toolbar toggles it." } diff --git a/src/grafo-vista.js b/src/grafo-vista.js index 14add64..14f9ce0 100644 --- a/src/grafo-vista.js +++ b/src/grafo-vista.js @@ -15,12 +15,14 @@ const t = vscode.l10n.t; const PAGINA = 300; const MAX_RECARGA = 3 * PAGINA; // tras una acción no se vuelve a pedir todo lo que se haya cargado con scroll const SHA = /^[0-9a-f]{40,64}$/; +const RESALTAR = 'graph.highlightCurrentBranch'; +const resaltarAhora = () => vscode.workspace.getConfiguration('gitLore').get(RESALTAR, false) === true; // no es hexadecimal: nunca pasa por SHA ni llega a git const PENDIENTES = 'pendientes'; const paneles = new Map(); // raíz → panel const vistas = new Map(); // id opaco del panel → { repo, recargar }: el menú contextual dice de qué panel viene -function html(webview, raizExt, nonce, id) { +function html(webview, raizExt, nonce, id, resaltar) { const recurso = f => webview.asWebviewUri(vscode.Uri.joinPath(raizExt, 'media', f)); const textos = { copiado: t('Copied'), sinCommits: t('No commits'), copiar: t('Copy SHA'), ficheros: t('Files'), padres: t('Parents'), @@ -43,7 +45,7 @@ function html(webview, raizExt, nonce, id) { - + @@ -52,7 +54,7 @@ function html(webview, raizExt, nonce, id) { - + `; @@ -220,6 +222,16 @@ function abrir(context, repo) { alcance = m.valor; return cargar(true); } + // el botón del grafo cambia el ajuste: así lo recuerdan los demás paneles y las próximas sesiones + if (m.tipo === 'resaltar' && typeof m.valor === 'boolean') { + const cfg = vscode.workspace.getConfiguration('gitLore'); + const enWorkspace = cfg.inspect(RESALTAR).workspaceValue !== undefined; + return cfg.update(RESALTAR, m.valor, enWorkspace ? vscode.ConfigurationTarget.Workspace : vscode.ConfigurationTarget.Global) + .then(undefined, e => { + vscode.window.showErrorMessage(e.message); + enviar({ tipo: 'resaltar', valor: resaltarAhora() }); // el botón cambió antes de guardar: vuelve al real + }); + } if (m.tipo === 'verCambios') { return vscode.commands.executeCommand('workbench.view.scm'); } if (m.tipo === 'fetch') { return repo.fetch({ all: true }) @@ -236,6 +248,9 @@ function abrir(context, repo) { if (m.tipo === 'remoto') { return abrirEnRemoto(repo, m.sha).then(undefined, fallo); } if (m.tipo === 'copiar') { return copiarSha(m.sha); } }), + vscode.workspace.onDidChangeConfiguration(e => { + if (e.affectsConfiguration(`gitLore.${RESALTAR}`)) { enviar({ tipo: 'resaltar', valor: resaltarAhora() }); } + }), ]; // crear una rama o un tag desde la terminal no dispara onDidChange: se vigilan los ficheros de refs @@ -258,7 +273,7 @@ function abrir(context, repo) { clearTimeout(esperaRefs); }); - panel.webview.html = html(panel.webview, context.extensionUri, crypto.randomBytes(16).toString('base64'), id); + panel.webview.html = html(panel.webview, context.extensionUri, crypto.randomBytes(16).toString('base64'), id, resaltarAhora()); } function registrar(context, protegido) {