mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-10-20 20:22:10 +00:00
Merge branch 'fix-mimepat-guess-mime-type' of https://github.com/devangpratap/kitty
Some checks are pending
CI / Linux (python=3.14 cc=clang sanitize=1) (push) Waiting to run
CI / Linux (python=3.12 cc=gcc sanitize=0) (push) Waiting to run
CI / Linux (python=3.13 cc=gcc sanitize=1) (push) Waiting to run
CI / Linux package (push) Waiting to run
CI / Bundle test (macos-latest) (push) Waiting to run
CI / Bundle test (ubuntu-latest) (push) Waiting to run
CI / macOS Brew (push) Waiting to run
CI / Test ./dev.sh and benchmark (push) Waiting to run
CodeQL / CodeQL-Build (actions, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, macos-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (go, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (python, ubuntu-latest) (push) Waiting to run
Depscan / Scan dependencies for vulnerabilities (push) Waiting to run
Some checks are pending
CI / Linux (python=3.14 cc=clang sanitize=1) (push) Waiting to run
CI / Linux (python=3.12 cc=gcc sanitize=0) (push) Waiting to run
CI / Linux (python=3.13 cc=gcc sanitize=1) (push) Waiting to run
CI / Linux package (push) Waiting to run
CI / Bundle test (macos-latest) (push) Waiting to run
CI / Bundle test (ubuntu-latest) (push) Waiting to run
CI / macOS Brew (push) Waiting to run
CI / Test ./dev.sh and benchmark (push) Waiting to run
CodeQL / CodeQL-Build (actions, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, macos-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (go, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (python, ubuntu-latest) (push) Waiting to run
Depscan / Scan dependencies for vulnerabilities (push) Waiting to run
This commit is contained in:
commit
1d67ecd47c
2 changed files with 15 additions and 11 deletions
|
|
@ -4,7 +4,6 @@ package cli
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"mime"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
|
|
@ -191,16 +190,7 @@ func complete_by_mimepat(prefix, cwd string, patterns []string) []string {
|
|||
if all_allowed {
|
||||
return true
|
||||
}
|
||||
idx := strings.Index(name, ".")
|
||||
if idx < 1 {
|
||||
return false
|
||||
}
|
||||
ext := name[idx:]
|
||||
mt := mime.TypeByExtension(ext)
|
||||
if mt == "" {
|
||||
ext = filepath.Ext(name)
|
||||
mt = mime.TypeByExtension(ext)
|
||||
}
|
||||
mt := utils.GuessMimeType(name)
|
||||
if mt == "" {
|
||||
return false
|
||||
}
|
||||
|
|
|
|||
|
|
@ -124,6 +124,20 @@ func TestCompleteFiles(t *testing.T) {
|
|||
if !found {
|
||||
t.Fatalf("Directory containing only an uppercase extension match not completed by FnmatchCompleter: %#v", c.Groups)
|
||||
}
|
||||
|
||||
// mime types kitty knows about but the Go stdlib does not
|
||||
create("zz.py")
|
||||
c = NewCompletions()
|
||||
MimepatCompleter("", CWD, "text/*")(c, "zz", 0)
|
||||
found = false
|
||||
for _, g := range c.Groups {
|
||||
for _, m := range g.Matches {
|
||||
found = found || m.Word == "zz.py"
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
t.Fatalf("File with a mime type known only to kitty not completed by MimepatCompleter: %#v", c.Groups)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCompleteExecutables(t *testing.T) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue