From 3cfe3a35e26d768398f2d2c037d9945c7dd9b2e7 Mon Sep 17 00:00:00 2001 From: Christopher Dignam Date: Sat, 14 Mar 2026 10:15:25 -0400 Subject: [PATCH 1/4] Substring pattern match --- CHANGELOG.md | 6 ++++++ src/codeowners-hover-provider.ts | 6 +----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 26da346..b4d4ddd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## 4.2.0 - 2026-03-14 + +### Changed + +- Adjust hover text for substring vs full path matches (#). + ## 4.1.0 - 2024-04-13 ### Changed diff --git a/src/codeowners-hover-provider.ts b/src/codeowners-hover-provider.ts index 1d112a3..cbf2d0a 100644 --- a/src/codeowners-hover-provider.ts +++ b/src/codeowners-hover-provider.ts @@ -42,11 +42,7 @@ export class CodeownersHoverProvider implements vscode.HoverProvider { range, contents: [ x, - isPattern - ? "Matches all files with same name" - : isDirectory - ? `Matches all files in directory and subdirectories` - : `Matches path exactly`, + isPattern ? "Substring pattern match" : `Matches path exactly`, ], } } From 0e5375810841e77662d4edb051479b3b6ad46ffc Mon Sep 17 00:00:00 2001 From: Christopher Dignam Date: Sat, 14 Mar 2026 10:16:22 -0400 Subject: [PATCH 2/4] version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ece2ea5..42e9f51 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "Quickly see GitHub Code Owners for the current file. Add syntax highlighting for CODEOWNERS files.", "publisher": "chdsbd", "license": "SEE LICENSE IN LICENSE", - "version": "4.1.0", + "version": "4.2.0", "icon": "images/logo256.png", "homepage": "https://github.com/chdsbd/vscode-github-code-owners/blob/master/README.md", "keywords": [ From 0b5826b7c92939a4046e136ae6f36c221a33874a Mon Sep 17 00:00:00 2001 From: Christopher Dignam Date: Sat, 14 Mar 2026 10:23:07 -0400 Subject: [PATCH 3/4] add more information to hover --- src/codeowners-hover-provider.ts | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/src/codeowners-hover-provider.ts b/src/codeowners-hover-provider.ts index cbf2d0a..1682a7e 100644 --- a/src/codeowners-hover-provider.ts +++ b/src/codeowners-hover-provider.ts @@ -29,7 +29,9 @@ export class CodeownersHoverProvider implements vscode.HoverProvider { const x = new vscode.MarkdownString() x.appendCodeblock(m) - const isPattern = !m.startsWith("/") + const hasLeadingSlash = m.startsWith("/") + const hasTrailingSlash = m.endsWith("/") + const hasTrailingGlob = m.endsWith("/*") const range = new vscode.Range( new vscode.Position(position.line, idx), @@ -38,12 +40,30 @@ export class CodeownersHoverProvider implements vscode.HoverProvider { if (!range.contains(position)) { return { contents: [] } } + + const lines: string[] = [] + + if (hasLeadingSlash) { + lines.push("**Anchored to repo root** — only matches at the top level") + } else { + lines.push( + "**Matches at any depth** — applies to this path anywhere in the repository)", + ) + } + + if (hasTrailingGlob) { + lines.push( + "**Shallow match** — covers only direct children, not subdirectories", + ) + } else if (hasTrailingSlash) { + lines.push( + "**Recursive directory match** — covers the directory and all its contents at any depth", + ) + } + return { range, - contents: [ - x, - isPattern ? "Substring pattern match" : `Matches path exactly`, - ], + contents: [x, lines.join("\n\n")], } } } From 6e675c088da7483bfd85a0fe10b906913273cb88 Mon Sep 17 00:00:00 2001 From: Christopher Dignam Date: Sat, 14 Mar 2026 10:28:17 -0400 Subject: [PATCH 4/4] dead code --- src/codeowners-hover-provider.ts | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/src/codeowners-hover-provider.ts b/src/codeowners-hover-provider.ts index 1682a7e..5330e4d 100644 --- a/src/codeowners-hover-provider.ts +++ b/src/codeowners-hover-provider.ts @@ -1,6 +1,4 @@ import vscode from "vscode" -import { dirname } from "path" -import fs from "fs" export class CodeownersHoverProvider implements vscode.HoverProvider { provideHover( @@ -14,18 +12,6 @@ export class CodeownersHoverProvider implements vscode.HoverProvider { } const idx = line.text.indexOf(m) - const workspaceDir = dirname(dirname(document.uri.fsPath)) - const myPath = workspaceDir + "/" + m - - let isDirectory: boolean | null = null - try { - isDirectory = fs.statSync(myPath).isDirectory() - } catch (e) { - // @ts-expect-error we should see this error. - if (e.code !== "ENOENT") { - console.error("github-code-owners", e) - } - } const x = new vscode.MarkdownString() x.appendCodeblock(m)