summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xmake/core/base/text.lua6
-rw-r--r--xmake/modules/private/utils/complete.lua2
2 files changed, 5 insertions, 3 deletions
diff --git a/xmake/core/base/text.lua b/xmake/core/base/text.lua
index 38f6912d9..cd7c889c5 100644
--- a/xmake/core/base/text.lua
+++ b/xmake/core/base/text.lua
@@ -44,13 +44,15 @@ function text._lastwbr(str, width, wordbreak)
end
local range = str:sub(1, width)
- local poss = range:reverse():find("[%s-]")
+ local range_r = range:reverse()
+ -- break at spaces and '-'' first, then try other candidates
+ local poss = range_r:find("[%s-]") or range_r:find("[%%=%)]")
if poss then
return #range - poss + 1
end
-- not found in range, try afterwards
- poss = str:find("[%s-]", width + 1)
+ poss = str:find("[%s-%%=%)]", width + 1)
if poss then
return poss
end
diff --git a/xmake/modules/private/utils/complete.lua b/xmake/modules/private/utils/complete.lua
index 781e98367..88b7d6ce4 100644
--- a/xmake/modules/private/utils/complete.lua
+++ b/xmake/modules/private/utils/complete.lua
@@ -282,7 +282,7 @@ function main(pos, config, ...)
_complete(argv, "")
else
local completing = table.remove(argv)
- _complete(argv, completing)
+ _complete(argv, completing or "")
end
end