Skip to content

Commit

Permalink
fix windowHints bugs with utf8 chars
Browse files Browse the repository at this point in the history
1. Fix window titles broken from truncating
2. When using hint chars vimperator, use the parent app's file name as a fallback, in case the app's title starts with a utf8 char.
  • Loading branch information
twio142 authored and cmsj committed Mar 6, 2023
1 parent 01a8cbc commit 1688862
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions extensions/hints/hints.lua
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ function hints.displayHintsForDict(dict, prefixstring, showTitles, allowNonStand
local suffixString = ""
if showTitles then
local win_title = win:title()
if hints.titleMaxSize > 1 and #win_title > hints.titleMaxSize then
local end_idx = math.max(0, hints.titleMaxSize-3)
if hints.titleMaxSize > 1 and utf8.len(win_title) > hints.titleMaxSize then
local end_idx = utf8.offset(win_title, math.max(0, hints.titleMaxSize-3))-1
win_title = string.sub(win_title, 1, end_idx) .. "..."
end
suffixString = ": "..win_title
Expand Down Expand Up @@ -236,6 +236,9 @@ function hints.windowHints(windows, callback, allowNonStandard)
if app and app:bundleID() and isValidWindow(win, allowNonStandard) then
if hints.style == "vimperator" then
local appchar = string.upper(string.sub(app:title(), 1, 1))
if hintDict[appchar] == nil then
appchar = string.upper(string.sub(string.gsub(app:path(), "(%w+)/", ""), 2, 2))
end
if hintDict[appchar] == nil then
hintDict[appchar] = {}
end
Expand Down

0 comments on commit 1688862

Please sign in to comment.