patch 9.1.1835: completion: not possible to style popup borders globally

Commit: 
https://github.com/vim/vim/commit/474b981e40ce211dc3498186ba78ec8461efb9c1
Author: Girish Palya <[email protected]>
Date:   Tue Oct 7 20:43:06 2025 +0000

    patch 9.1.1835: completion: not possible to style popup borders globally
    
    Problem:  not possible to style popup borders globally
    Solution: Add the 'pumborder' option (Girish Palya)
    
    This commit introduces a new global option, 'pumborder' ('pb'), that
    allows users to define borders and optional decorations for the
    completion popup menu.
    
    ```
    Defines a border and optional decorations for the popup menu in
    completion.  The value is a comma-separated list of keywords.
    
    Border styles (at most one):
    "single"singleuse thin box-drawing characters
    "double"doubleuse double-line box-drawing characters
    "round"rounduse rounded corners
    "ascii"asciiuse ASCII characters (-, |, +)
    "custom:XXXXXXXX"
        use eight characters given after "custom:",
        in order: top, right, bottom, left,
        topleft, topright, botright, botleft
    
    Additional flags:
    "margin"marginadds one-cell spacing inside the left and right border
    "shadow"shadowdraws a shadow at the right and bottom edges
    
    Highlight groups:
    |hl-PmenuBorder|hl-PmenuBorderused for the border characters
    |hl-PmenuShadow|hl-PmenuShadowused for the shadow
    
    Examples: >
      :set pumborder=single
      :set pumborder=double,margin,shadow
      :set pumborder=custom:─│─│┌┐┘└,shadow
    
    Border styles using box-drawing characters ("single", "double",
    "round") are only available when |'encoding'| is "utf-8" and
    |'ambiwidth'| is "single".  "margin" requires a border style.
    See also: |ins-completion-menu|.
    ```
    
    fixes: https://github.com/vim/vim/pull/18441#issuecomment-3360188458
    closes: #18486
    closes: #17091
    
    Signed-off-by: Girish Palya <[email protected]>
    Signed-off-by: Christian Brabandt <[email protected]>

diff --git a/ci/hlgroups.ignore b/ci/hlgroups.ignore
index ba31274d0..a046eb127 100644
--- a/ci/hlgroups.ignore
+++ b/ci/hlgroups.ignore
@@ -33,6 +33,7 @@ Pmenu
 PmenuSbar
 PmenuSel
 PmenuThumb
+PmenuShadow
 Question
 Scrollbar
 Search
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
index 00997a045..12483baa8 100644
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -4683,7 +4683,8 @@ A jump table for the options with a short description can 
be found at |Q_op|.
                                     =:PmenuSel, k:PmenuMatch,<:PmenuMatchSel,
                                     [:PmenuKind,]:PmenuKindSel,
                                     {:PmenuExtra,}:PmenuExtraSel,
-                                    x:PmenuSbar,X:PmenuThumb,*:TabLine,
+                                    x:PmenuSbar,X:PmenuThumb,j:PmenuBorder,
+                                    H:PmenuShadow,*:TabLine,
                                     #:TabLineSel,_:TabLineFill,!:CursorColumn,
                                     .:CursorLine,o:ColorColumn,q:QuickFixLine,
                                     z:StatusLineTerm,Z:StatusLineTermNC,
@@ -4750,6 +4751,8 @@ A jump table for the options with a short description can 
be found at |Q_op|.
        |hl-PmenuThumb|  X  popup menu scrollbar thumb
        |hl-PmenuMatch|  k  popup menu matched text
        |hl-PmenuMatchSel| <  popup menu matched text in selected line
+       |hl-PmenuBorder|   j  popup menu border characters
+       |hl-PmenuShadow|   H  popup menu shadow
        |hl-PreInsert|   I  text inserted when "preinsert" is in 'completeopt'
 
        The display modes are:
@@ -6787,6 +6790,40 @@ A jump table for the options with a short description 
can be found at |Q_op|.
                        global
        When on a ":" prompt is used in Ex mode.
 
+                                               *'pumborder'* *'pb'*
+'pumborder' 'pb'       string  (default "")
+                       global
+       Defines a border and optional decorations for the popup menu in
+       completion.  The value is a comma-separated list of keywords.
+
+       Border styles (at most one):
+       "single"        use thin box-drawing characters
+       "double"        use double-line box-drawing characters
+       "round"         use rounded corners
+       "ascii"         use ASCII characters (-, |, +)
+       "custom:X;X;X;X;X;X;X;X"
+                       use eight characters separated by semicolons, in the
+                       order: top, right, bottom, left,
+                       topleft, topright, botright, botleft
+
+       Additional flags:
+       "margin"        adds one-cell spacing inside the left and right border
+       "shadow"        draws a shadow at the right and bottom edges
+
+       Highlight groups:
+       |hl-PmenuBorder|        used for the border characters
+       |hl-PmenuShadow|        used for the shadow
+
+       Examples: >
+               :set pumborder=single
+               :set pumborder=double,margin,shadow
+               :set pumborder=custom:─;│;─;│;┌;┐;┘;└,shadow
+<
+       Border styles using box-drawing characters ("single", "double",
+       "round") are only available when |'encoding'| is "utf-8" and
+       |'ambiwidth'| is "single".  "margin" requires a border style.
+       See also: |ins-completion-menu|.
+
                                                *'pumheight'* *'ph'*
 'pumheight' 'ph'       number  (default 0)
                        global
diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt
index 40cd6e7bf..0545093bb 100644
--- a/runtime/doc/syntax.txt
+++ b/runtime/doc/syntax.txt
@@ -6024,6 +6024,11 @@ PmenuMatch       Popup menu: Matched text in normal 
item. Applied in
                                                        *hl-PmenuMatchSel*
 PmenuMatchSel  Popup menu: Matched text in selected item. Applied in
                combination with |hl-PmenuSel|.
+                                                       *hl-PmenuBorder*
+PmenuBorder    Popup menu: Border characters.
+               Linked to |hl-Pmenu| by default.
+                                                       *hl-PmenuShadow*
+PmenuShadow    Popup menu: Used for shadow.
                                                        *hl-ComplMatchIns*
 ComplMatchIns  Matched text of the currently inserted completion.
                                                        *hl-PreInsert*
diff --git a/runtime/doc/tags b/runtime/doc/tags
index 8c8807188..cfb54e16f 100644
--- a/runtime/doc/tags
+++ b/runtime/doc/tags
@@ -858,6 +858,7 @@ $quote      eval.txt        /*$quote*
 'patchexpr'    options.txt     /*'patchexpr'*
 'patchmode'    options.txt     /*'patchmode'*
 'path' options.txt     /*'path'*
+'pb'   options.txt     /*'pb'*
 'pdev' options.txt     /*'pdev'*
 'penc' options.txt     /*'penc'*
 'perldll'      options.txt     /*'perldll'*
@@ -887,6 +888,7 @@ $quote      eval.txt        /*$quote*
 'printoptions' options.txt     /*'printoptions'*
 'prompt'       options.txt     /*'prompt'*
 'pt'   options.txt     /*'pt'*
+'pumborder'    options.txt     /*'pumborder'*
 'pumheight'    options.txt     /*'pumheight'*
 'pummaxwidth'  options.txt     /*'pummaxwidth'*
 'pumwidth'     options.txt     /*'pumwidth'*
@@ -8384,6 +8386,7 @@ hl-MsgArea        syntax.txt      /*hl-MsgArea*
 hl-NonText     syntax.txt      /*hl-NonText*
 hl-Normal      syntax.txt      /*hl-Normal*
 hl-Pmenu       syntax.txt      /*hl-Pmenu*
+hl-PmenuBorder syntax.txt      /*hl-PmenuBorder*
 hl-PmenuExtra  syntax.txt      /*hl-PmenuExtra*
 hl-PmenuExtraSel       syntax.txt      /*hl-PmenuExtraSel*
 hl-PmenuKind   syntax.txt      /*hl-PmenuKind*
@@ -8392,6 +8395,7 @@ hl-PmenuMatch     syntax.txt      /*hl-PmenuMatch*
 hl-PmenuMatchSel       syntax.txt      /*hl-PmenuMatchSel*
 hl-PmenuSbar   syntax.txt      /*hl-PmenuSbar*
 hl-PmenuSel    syntax.txt      /*hl-PmenuSel*
+hl-PmenuShadow syntax.txt      /*hl-PmenuShadow*
 hl-PmenuThumb  syntax.txt      /*hl-PmenuThumb*
 hl-PopupNotification   syntax.txt      /*hl-PopupNotification*
 hl-PopupSelected       syntax.txt      /*hl-PopupSelected*
diff --git a/runtime/doc/version9.txt b/runtime/doc/version9.txt
index fa73efcc8..0a662f7cc 100644
--- a/runtime/doc/version9.txt
+++ b/runtime/doc/version9.txt
@@ -41838,9 +41838,11 @@ Highlighting: ~
 |hl-ComplMatchIns|     matched text of the currently inserted completion
 |hl-DiffTextAdd|       added text within a changed line
 |hl-MsgArea|           highlighting of the Command-line and messages area
+|hl-PmenuBorder|       Popup menu: highlighting of popup border characters
 |hl-PmenuMatch|                Popup menu: highlighting of matched text
 |hl-PmenuMatchSel|     Popup menu: highlighting of matched text in selected
                        line
+|hl-PmenuShadow|       Popup menu: highlighting of the popup shadow
 |hl-PreInsert|         highlighting for completion preinserted text
 |hl-TabPanel|          |tabpanel|: not active tab page label
 |hl-TabPanelFill|      |tabpanel|: filler space
@@ -41880,6 +41882,7 @@ Options: ~
 'lhistory'             Size of the location list stack |quickfix-stack|
 'maxsearchcount'       Set the maximum number for search-stat |shm-S|
 'messagesopt'          configure |:messages| and |hit-enter| prompt
+'pumborder'            define popup border and decorations
 'pummaxwidth'          maximum width for the completion popup menu
 'showtabpanel'         When to show the |tabpanel|
 'tabclose'             Which tab page to focus after closing a tab page
diff --git a/runtime/optwin.vim b/runtime/optwin.vim
index 2bf20585c..972c77471 100644
--- a/runtime/optwin.vim
+++ b/runtime/optwin.vim
@@ -1,7 +1,7 @@
 " These commands create the option window.
 "
 " Maintainer:  The Vim Project <https://github.com/vim/vim>
-" Last Change: 2025 Sep 30
+" Last Change: 2025 Oct 07
 " Former Maintainer:   Bram Moolenaar <[email protected]>
 
 " If there already is an option window, jump to that one.
@@ -900,6 +900,8 @@ if has("insert_expand")
   call <SID>OptionG("pw", &pw)
   call <SID>AddOption("pummaxwidth", gettext("maximum width of the popup 
menu"))
   call <SID>OptionG("pmw", &pmw)
+  call <SID>AddOption("pumborder", gettext("popup border style"))
+  call <SID>OptionG("pb", &pb)
   call <SID>AddOption("completefunc", gettext("user defined function for 
Insert mode completion"))
   call append("$", "   " .. s:local_to_buffer)
   call <SID>OptionL("cfu")
diff --git a/runtime/syntax/vim.vim b/runtime/syntax/vim.vim
index 1e3ded37a..7eb2bd0da 100644
--- a/runtime/syntax/vim.vim
+++ b/runtime/syntax/vim.vim
@@ -69,8 +69,8 @@ syn keyword vimOption contained co columns com comments cms 
commentstring cp com
 syn keyword vimOption contained ef errorfile efm errorformat ek esckeys ei 
eventignore eiw eventignorewin et expandtab ex exrc fenc fileencoding fencs 
fileencodings ff fileformat ffs fileformats fic fileignorecase ft filetype fcs 
fillchars ffu findfunc fixeol fixendofline fcl foldclose fdc foldcolumn fen 
foldenable fde foldexpr fdi foldignore fdl foldlevel fdls foldlevelstart fmr 
foldmarker fdm foldmethod fml foldminlines fdn foldnestmax fdo foldopen fdt 
foldtext fex formatexpr flp formatlistpat fo formatoptions fp formatprg fs 
fsync gd gdefault gfm grepformat gp grepprg gcr guicursor gfn guifont gfs 
guifontset gfw guifontwide ghr guiheadroom gli guiligatures go guioptions 
guipty gtl guitablabel gtt guitabtooltip hf helpfile hh helpheight hlg helplang 
hid hidden skipwhite nextgroup=vimSetEqual,vimSetMod
 syn keyword vimOption contained hl highlight hi history hk hkmap hkp hkmapp 
hls hlsearch icon iconstring ic ignorecase imaf imactivatefunc imak 
imactivatekey imc imcmdline imd imdisable imi iminsert ims imsearch imsf 
imstatusfunc imst imstyle inc include inex includeexpr is incsearch inde 
indentexpr indk indentkeys inf infercase im insertmode ise isexpand isf isfname 
isi isident isk iskeyword isp isprint js joinspaces jop jumpoptions key kmp 
keymap km keymodel kpc keyprotocol kp keywordprg lmap langmap lm langmenu lnr 
langnoremap lrm langremap ls laststatus lz lazyredraw lhi lhistory lbr 
linebreak lines lsp linespace lisp lop lispoptions lw lispwords list lcs 
listchars lpl loadplugins luadll magic mef makeef menc makeencoding mp makeprg 
mps matchpairs mat matchtime skipwhite nextgroup=vimSetEqual,vimSetMod
 syn keyword vimOption contained mco maxcombine mfd maxfuncdepth mmd 
maxmapdepth mm maxmem mmp maxmempattern mmt maxmemtot msc maxsearchcount mis 
menuitems mopt messagesopt msm mkspellmem ml modeline mle modelineexpr mls 
modelines ma modifiable mod modified more mouse mousef mousefocus mh mousehide 
mousem mousemodel mousemev mousemoveevent mouses mouseshape mouset mousetime 
mzq mzquantum mzschemedll mzschemegcdll nf nrformats nu number nuw numberwidth 
ofu omnifunc odev opendevice opfunc operatorfunc ost osctimeoutlen pp packpath 
para paragraphs paste pt pastetoggle pex patchexpr pm patchmode pa path perldll 
pi preserveindent pvh previewheight pvp previewpopup pvw previewwindow pdev 
printdevice penc printencoding pexpr printexpr pfn printfont pheader 
printheader skipwhite nextgroup=vimSetEqual,vimSetMod
-syn keyword vimOption contained pmbcs printmbcharset pmbfn printmbfont popt 
printoptions prompt ph pumheight pmw pummaxwidth pw pumwidth pythondll 
pythonhome pythonthreedll pythonthreehome pyx pyxversion qftf quickfixtextfunc 
qe quoteescape ro readonly rdt redrawtime re regexpengine rnu relativenumber 
remap rop renderoptions report rs restorescreen ri revins rl rightleft rlc 
rightleftcmd rubydll ru ruler ruf rulerformat rtp runtimepath scr scroll scb 
scrollbind scf scrollfocus sj scrolljump so scrolloff sbo scrollopt sect 
sections secure sel selection slm selectmode ssop sessionoptions sh shell shcf 
shellcmdflag sp shellpipe shq shellquote srr shellredir ssl shellslash stmp 
shelltemp st shelltype sxe shellxescape sxq shellxquote sr shiftround sw 
shiftwidth shm shortmess skipwhite nextgroup=vimSetEqual,vimSetMod
-syn keyword vimOption contained sn shortname sbr showbreak sc showcmd sloc 
showcmdloc sft showfulltag sm showmatch smd showmode stal showtabline stpl 
showtabpanel ss sidescroll siso sidescrolloff scl signcolumn scs smartcase si 
smartindent sta smarttab sms smoothscroll sts softtabstop spell spc 
spellcapcheck spf spellfile spl spelllang spo spelloptions sps spellsuggest sb 
splitbelow spk splitkeep spr splitright sol startofline stl statusline su 
suffixes sua suffixesadd swf swapfile sws swapsync swb switchbuf smc synmaxcol 
syn syntax tcl tabclose tal tabline tpm tabpagemax tpl tabpanel tplo 
tabpanelopt ts tabstop tbs tagbsearch tc tagcase tfu tagfunc tl taglength tr 
tagrelative tag tags tgst tagstack tcldll term tbidi termbidi tenc termencoding 
tgc termguicolors skipwhite nextgroup=vimSetEqual,vimSetMod
+syn keyword vimOption contained pmbcs printmbcharset pmbfn printmbfont popt 
printoptions prompt pb pumborder ph pumheight pmw pummaxwidth pw pumwidth 
pythondll pythonhome pythonthreedll pythonthreehome pyx pyxversion qftf 
quickfixtextfunc qe quoteescape ro readonly rdt redrawtime re regexpengine rnu 
relativenumber remap rop renderoptions report rs restorescreen ri revins rl 
rightleft rlc rightleftcmd rubydll ru ruler ruf rulerformat rtp runtimepath scr 
scroll scb scrollbind scf scrollfocus sj scrolljump so scrolloff sbo scrollopt 
sect sections secure sel selection slm selectmode ssop sessionoptions sh shell 
shcf shellcmdflag sp shellpipe shq shellquote srr shellredir ssl shellslash 
stmp shelltemp st shelltype sxe shellxescape sxq shellxquote sr shiftround sw 
shiftwidth skipwhite nextgroup=vimSetEqual,vimSetMod
+syn keyword vimOption contained shm shortmess sn shortname sbr showbreak sc 
showcmd sloc showcmdloc sft showfulltag sm showmatch smd showmode stal 
showtabline stpl showtabpanel ss sidescroll siso sidescrolloff scl signcolumn 
scs smartcase si smartindent sta smarttab sms smoothscroll sts softtabstop 
spell spc spellcapcheck spf spellfile spl spelllang spo spelloptions sps 
spellsuggest sb splitbelow spk splitkeep spr splitright sol startofline stl 
statusline su suffixes sua suffixesadd swf swapfile sws swapsync swb switchbuf 
smc synmaxcol syn syntax tcl tabclose tal tabline tpm tabpagemax tpl tabpanel 
tplo tabpanelopt ts tabstop tbs tagbsearch tc tagcase tfu tagfunc tl taglength 
tr tagrelative tag tags tgst tagstack tcldll term tbidi termbidi tenc 
termencoding tgc termguicolors skipwhite nextgroup=vimSetEqual,vimSetMod
 syn keyword vimOption contained twk termwinkey twsl termwinscroll tws 
termwinsize twt termwintype terse ta textauto tx textmode tw textwidth tsr 
thesaurus tsrfu thesaurusfunc top tildeop to timeout tm timeoutlen title 
titlelen titleold titlestring tb toolbar tbis toolbariconsize ttimeout ttm 
ttimeoutlen tbi ttybuiltin tf ttyfast ttym ttymouse tsl ttyscroll tty ttytype 
udir undodir udf undofile ul undolevels ur undoreload uc updatecount ut 
updatetime vsts varsofttabstop vts vartabstop vbs verbose vfile verbosefile 
vdir viewdir vop viewoptions vi viminfo vif viminfofile ve virtualedit vb 
visualbell warn wiv weirdinvert ww whichwrap wc wildchar wcm wildcharm wig 
wildignore wic wildignorecase wmnu wildmenu wim wildmode wop wildoptions wak 
winaltkeys wcr wincolor wi window skipwhite nextgroup=vimSetEqual,vimSetMod
 syn keyword vimOption contained wfb winfixbuf wfh winfixheight wfw winfixwidth 
wh winheight wmh winminheight wmw winminwidth winptydll wiw winwidth wse wlseat 
wst wlsteal wtm wltimeoutlen wrap wm wrapmargin ws wrapscan write wa writeany 
wb writebackup wd writedelay xtermcodes skipwhite 
nextgroup=vimSetEqual,vimSetMod
 
@@ -108,9 +108,9 @@ syn keyword vimOptionVarName contained co columns com 
comments cms commentstring
 syn keyword vimOptionVarName contained eb errorbells ef errorfile efm 
errorformat ek esckeys ei eventignore eiw eventignorewin et expandtab ex exrc 
fenc fileencoding fencs fileencodings ff fileformat ffs fileformats fic 
fileignorecase ft filetype fcs fillchars ffu findfunc fixeol fixendofline fcl 
foldclose fdc foldcolumn fen foldenable fde foldexpr fdi foldignore fdl 
foldlevel fdls foldlevelstart fmr foldmarker fdm foldmethod fml foldminlines 
fdn foldnestmax fdo foldopen fdt foldtext fex formatexpr flp formatlistpat fo 
formatoptions fp formatprg fs fsync gd gdefault gfm grepformat gp grepprg gcr 
guicursor gfn guifont gfs guifontset gfw guifontwide ghr guiheadroom gli 
guiligatures go guioptions guipty gtl guitablabel gtt guitabtooltip hf helpfile 
hh helpheight
 syn keyword vimOptionVarName contained hlg helplang hid hidden hl highlight hi 
history hk hkmap hkp hkmapp hls hlsearch icon iconstring ic ignorecase imaf 
imactivatefunc imak imactivatekey imc imcmdline imd imdisable imi iminsert ims 
imsearch imsf imstatusfunc imst imstyle inc include inex includeexpr is 
incsearch inde indentexpr indk indentkeys inf infercase im insertmode ise 
isexpand isf isfname isi isident isk iskeyword isp isprint js joinspaces jop 
jumpoptions key kmp keymap km keymodel kpc keyprotocol kp keywordprg lmap 
langmap lm langmenu lnr langnoremap lrm langremap ls laststatus lz lazyredraw 
lhi lhistory lbr linebreak lines lsp linespace lisp lop lispoptions lw 
lispwords list lcs listchars lpl loadplugins luadll magic mef makeef menc 
makeencoding mp makeprg
 syn keyword vimOptionVarName contained mps matchpairs mat matchtime mco 
maxcombine mfd maxfuncdepth mmd maxmapdepth mm maxmem mmp maxmempattern mmt 
maxmemtot msc maxsearchcount mis menuitems mopt messagesopt msm mkspellmem ml 
modeline mle modelineexpr mls modelines ma modifiable mod modified more mouse 
mousef mousefocus mh mousehide mousem mousemodel mousemev mousemoveevent mouses 
mouseshape mouset mousetime mzq mzquantum mzschemedll mzschemegcdll nf 
nrformats nu number nuw numberwidth ofu omnifunc odev opendevice opfunc 
operatorfunc ost osctimeoutlen pp packpath para paragraphs paste pt pastetoggle 
pex patchexpr pm patchmode pa path perldll pi preserveindent pvh previewheight 
pvp previewpopup pvw previewwindow pdev printdevice penc printencoding pexpr 
printexpr
-syn keyword vimOptionVarName contained pfn printfont pheader printheader pmbcs 
printmbcharset pmbfn printmbfont popt printoptions prompt ph pumheight pmw 
pummaxwidth pw pumwidth pythondll pythonhome pythonthreedll pythonthreehome pyx 
pyxversion qftf quickfixtextfunc qe quoteescape ro readonly rdt redrawtime re 
regexpengine rnu relativenumber remap rop renderoptions report rs restorescreen 
ri revins rl rightleft rlc rightleftcmd rubydll ru ruler ruf rulerformat rtp 
runtimepath scr scroll scb scrollbind scf scrollfocus sj scrolljump so 
scrolloff sbo scrollopt sect sections secure sel selection slm selectmode ssop 
sessionoptions sh shell shcf shellcmdflag sp shellpipe shq shellquote srr 
shellredir ssl shellslash stmp shelltemp st shelltype sxe shellxescape sxq 
shellxquote
-syn keyword vimOptionVarName contained sr shiftround sw shiftwidth shm 
shortmess sn shortname sbr showbreak sc showcmd sloc showcmdloc sft showfulltag 
sm showmatch smd showmode stal showtabline stpl showtabpanel ss sidescroll siso 
sidescrolloff scl signcolumn scs smartcase si smartindent sta smarttab sms 
smoothscroll sts softtabstop spell spc spellcapcheck spf spellfile spl 
spelllang spo spelloptions sps spellsuggest sb splitbelow spk splitkeep spr 
splitright sol startofline stl statusline su suffixes sua suffixesadd swf 
swapfile sws swapsync swb switchbuf smc synmaxcol syn syntax tcl tabclose tal 
tabline tpm tabpagemax tpl tabpanel tplo tabpanelopt ts tabstop tbs tagbsearch 
tc tagcase tfu tagfunc tl taglength tr tagrelative tag tags tgst tagstack 
tcldll term
-syn keyword vimOptionVarName contained tbidi termbidi tenc termencoding tgc 
termguicolors twk termwinkey twsl termwinscroll tws termwinsize twt termwintype 
terse ta textauto tx textmode tw textwidth tsr thesaurus tsrfu thesaurusfunc 
top tildeop to timeout tm timeoutlen title titlelen titleold titlestring tb 
toolbar tbis toolbariconsize ttimeout ttm ttimeoutlen tbi ttybuiltin tf ttyfast 
ttym ttymouse tsl ttyscroll tty ttytype udir undodir udf undofile ul undolevels 
ur undoreload uc updatecount ut updatetime vsts varsofttabstop vts vartabstop 
vbs verbose vfile verbosefile vdir viewdir vop viewoptions vi viminfo vif 
viminfofile ve virtualedit vb visualbell warn wiv weirdinvert ww whichwrap wc 
wildchar wcm wildcharm wig wildignore wic wildignorecase wmnu wildmenu
+syn keyword vimOptionVarName contained pfn printfont pheader printheader pmbcs 
printmbcharset pmbfn printmbfont popt printoptions prompt pb pumborder ph 
pumheight pmw pummaxwidth pw pumwidth pythondll pythonhome pythonthreedll 
pythonthreehome pyx pyxversion qftf quickfixtextfunc qe quoteescape ro readonly 
rdt redrawtime re regexpengine rnu relativenumber remap rop renderoptions 
report rs restorescreen ri revins rl rightleft rlc rightleftcmd rubydll ru 
ruler ruf rulerformat rtp runtimepath scr scroll scb scrollbind scf scrollfocus 
sj scrolljump so scrolloff sbo scrollopt sect sections secure sel selection slm 
selectmode ssop sessionoptions sh shell shcf shellcmdflag sp shellpipe shq 
shellquote srr shellredir ssl shellslash stmp shelltemp st shelltype sxe 
shellxescape
+syn keyword vimOptionVarName contained sxq shellxquote sr shiftround sw 
shiftwidth shm shortmess sn shortname sbr showbreak sc showcmd sloc showcmdloc 
sft showfulltag sm showmatch smd showmode stal showtabline stpl showtabpanel ss 
sidescroll siso sidescrolloff scl signcolumn scs smartcase si smartindent sta 
smarttab sms smoothscroll sts softtabstop spell spc spellcapcheck spf spellfile 
spl spelllang spo spelloptions sps spellsuggest sb splitbelow spk splitkeep spr 
splitright sol startofline stl statusline su suffixes sua suffixesadd swf 
swapfile sws swapsync swb switchbuf smc synmaxcol syn syntax tcl tabclose tal 
tabline tpm tabpagemax tpl tabpanel tplo tabpanelopt ts tabstop tbs tagbsearch 
tc tagcase tfu tagfunc tl taglength tr tagrelative tag tags tgst tagstack
+syn keyword vimOptionVarName contained tcldll term tbidi termbidi tenc 
termencoding tgc termguicolors twk termwinkey twsl termwinscroll tws 
termwinsize twt termwintype terse ta textauto tx textmode tw textwidth tsr 
thesaurus tsrfu thesaurusfunc top tildeop to timeout tm timeoutlen title 
titlelen titleold titlestring tb toolbar tbis toolbariconsize ttimeout ttm 
ttimeoutlen tbi ttybuiltin tf ttyfast ttym ttymouse tsl ttyscroll tty ttytype 
udir undodir udf undofile ul undolevels ur undoreload uc updatecount ut 
updatetime vsts varsofttabstop vts vartabstop vbs verbose vfile verbosefile 
vdir viewdir vop viewoptions vi viminfo vif viminfofile ve virtualedit vb 
visualbell warn wiv weirdinvert ww whichwrap wc wildchar wcm wildcharm wig 
wildignore wic wildignorecase wmnu wildmenu
 syn keyword vimOptionVarName contained wim wildmode wop wildoptions wak 
winaltkeys wcr wincolor wi window wfb winfixbuf wfh winfixheight wfw 
winfixwidth wh winheight wmh winminheight wmw winminwidth winptydll wiw 
winwidth wse wlseat wst wlsteal wtm wltimeoutlen wrap wm wrapmargin ws wrapscan 
write wa writeany wb writebackup wd writedelay xtermcodes
 " GEN_SYN_VIM: vimOption term output code variable, START_STR='syn keyword 
vimOptionVarName contained', END_STR=''
 syn keyword vimOptionVarName contained t_AB t_AF t_AU t_AL t_al t_bc t_BE t_BD 
t_cd t_ce t_Ce t_CF t_cl t_cm t_Co t_CS t_Cs t_cs t_CV t_da t_db t_DL t_dl t_ds 
t_Ds t_EC t_EI t_fs t_fd t_fe t_GP t_IE t_IS t_ke t_ks t_le t_mb t_md t_me t_mr 
t_ms t_nd t_op t_RF t_RB t_RC t_RI t_Ri t_RK t_RS t_RT t_RV t_Sb t_SC t_se t_Sf 
t_SH t_SI t_Si t_so t_SR t_sr t_ST t_Te t_te t_TE t_ti t_TI t_Ts t_ts t_u7 t_ue 
t_us t_Us t_ut t_vb t_ve t_vi t_VS t_vs t_WP t_WS t_XM t_xn t_xs t_ZH t_ZR t_8f 
t_8b t_8u t_xo
@@ -146,8 +146,8 @@ syn keyword vimGroup contained Added Bold BoldItalic 
Boolean Changed Character C
 
 " Default highlighting groups {{{2
 " GEN_SYN_VIM: vimHLGroup, START_STR='syn keyword vimHLGroup contained', 
END_STR=''
-syn keyword vimHLGroup contained ErrorMsg IncSearch ModeMsg NonText StatusLine 
StatusLineNC EndOfBuffer VertSplit VisualNOS DiffText DiffTextAdd PmenuSbar 
TabLineSel TabLineFill TabPanel TabPanelSel TabPanelFill Cursor lCursor 
TitleBar TitleBarNC QuickFixLine CursorLineSign CursorLineFold CurSearch 
PmenuKind PmenuKindSel PmenuMatch PmenuMatchSel PmenuExtra PmenuExtraSel 
PopupSelected MessageWindow PopupNotification PreInsert Normal Directory LineNr 
CursorLineNr MoreMsg Question Search SpellBad SpellCap SpellRare SpellLocal 
PmenuThumb Pmenu PmenuSel SpecialKey Title WarningMsg WildMenu Folded 
FoldColumn SignColumn Visual DiffAdd DiffChange DiffDelete TabLine CursorColumn 
CursorLine ColorColumn MatchParen StatusLineTerm StatusLineTermNC ToolbarLine 
ToolbarButton
-syn keyword vimHLGroup contained TitleBar TitleBarNC Menu Tooltip Scrollbar 
CursorIM ComplMatchIns LineNrAbove LineNrBelow MsgArea Terminal User1 User2 
User3 User4 User5 User6 User7 User8 User9
+syn keyword vimHLGroup contained ErrorMsg IncSearch ModeMsg NonText StatusLine 
StatusLineNC EndOfBuffer VertSplit VisualNOS DiffText DiffTextAdd PmenuSbar 
TabLineSel TabLineFill TabPanel TabPanelSel TabPanelFill Cursor lCursor 
TitleBar TitleBarNC QuickFixLine CursorLineSign CursorLineFold CurSearch 
PmenuKind PmenuKindSel PmenuMatch PmenuMatchSel PmenuExtra PmenuExtraSel 
PmenuBorder PopupSelected MessageWindow PopupNotification PreInsert Normal 
Directory LineNr CursorLineNr MoreMsg Question Search SpellBad SpellCap 
SpellRare SpellLocal PmenuThumb PmenuShadow Pmenu PmenuSel SpecialKey Title 
WarningMsg WildMenu Folded FoldColumn SignColumn Visual DiffAdd DiffChange 
DiffDelete TabLine CursorColumn CursorLine ColorColumn MatchParen 
StatusLineTerm StatusLineTermNC ToolbarLine
+syn keyword vimHLGroup contained ToolbarButton TitleBar TitleBarNC Menu 
Tooltip Scrollbar CursorIM ComplMatchIns LineNrAbove LineNrBelow MsgArea 
Terminal User1 User2 User3 User4 User5 User6 User7 User8 User9
 syn match vimHLGroup contained "\<Conceal\>"
 syn case match
 
diff --git a/src/highlight.c b/src/highlight.c
index 30489c212..b4e6cee07 100644
--- a/src/highlight.c
+++ b/src/highlight.c
@@ -270,6 +270,7 @@ static char *(highlight_init_both[]) = {
     "default link PmenuMatchSel PmenuSel",
     "default link PmenuExtra Pmenu",
     "default link PmenuExtraSel PmenuSel",
+    "default link PmenuBorder Pmenu",
     "default link PopupSelected PmenuSel",
     "default link MessageWindow WarningMsg",
     "default link PopupNotification WarningMsg",
@@ -304,6 +305,8 @@ static char *(highlight_init_light[]) = {
 #endif
     CENT("PmenuThumb ctermbg=Black",
         "PmenuThumb ctermbg=Black guibg=Black"),
+    CENT("PmenuShadow ctermbg=Black ctermfg=DarkGrey",
+        "PmenuShadow ctermbg=Black ctermfg=DarkGrey guibg=Black 
guifg=DarkGrey"),
     CENT("Pmenu ctermbg=LightMagenta ctermfg=Black",
         "Pmenu ctermbg=LightMagenta ctermfg=Black guibg=LightMagenta"),
     CENT("PmenuSel ctermbg=LightGrey ctermfg=Black",
@@ -395,6 +398,8 @@ static char *(highlight_init_dark[]) = {
 #endif
     CENT("PmenuThumb ctermbg=White",
         "PmenuThumb ctermbg=White guibg=White"),
+    CENT("PmenuShadow ctermbg=Black ctermfg=DarkGrey",
+        "PmenuShadow ctermbg=Black ctermfg=DarkGrey guibg=Black 
guifg=DarkGrey"),
     CENT("Pmenu ctermbg=Magenta ctermfg=Black",
         "Pmenu ctermbg=Magenta ctermfg=Black guibg=Magenta"),
     CENT("PmenuSel ctermbg=Black ctermfg=DarkGrey",
diff --git a/src/option.h b/src/option.h
index b8e616282..ac9dca9e2 100644
--- a/src/option.h
+++ b/src/option.h
@@ -555,6 +555,7 @@ EXTERN char_u       *p_csl;         // 'completeslash'
 EXTERN long    p_ph;           // 'pumheight'
 EXTERN long    p_pw;           // 'pumwidth'
 EXTERN long    p_pmw;          // 'pummaxwidth'
+EXTERN char_u  *p_pb;          // 'pumborder'
 EXTERN char_u  *p_com;         // 'comments'
 EXTERN char_u  *p_cpo;         // 'cpoptions'
 #ifdef FEAT_CSCOPE
diff --git a/src/optiondefs.h b/src/optiondefs.h
index 626823c16..a7b7f2e7e 100644
--- a/src/optiondefs.h
+++ b/src/optiondefs.h
@@ -310,7 +310,7 @@ struct vimoption
 # define ISP_LATIN1 (char_u *)"@,161-255"
 #endif
 
-# define HIGHLIGHT_INIT 
"8:SpecialKey,~:EndOfBuffer,@:NonText,d:Directory,e:ErrorMsg,i:IncSearch,l:Search,y:CurSearch,m:MoreMsg,M:ModeMsg,n:LineNr,a:LineNrAbove,b:LineNrBelow,N:CursorLineNr,G:CursorLineSign,O:CursorLineFold,r:Question,s:StatusLine,S:StatusLineNC,c:VertSplit,t:Title,v:Visual,V:VisualNOS,w:WarningMsg,W:WildMenu,f:Folded,F:FoldColumn,A:DiffAdd,C:DiffChange,D:DiffDelete,T:DiffText,E:DiffTextAdd,>:SignColumn,-:Conceal,B:SpellBad,P:SpellCap,R:SpellRare,L:SpellLocal,+:Pmenu,=:PmenuSel,k:PmenuMatch,<:PmenuMatchSel,[:PmenuKind,]:PmenuKindSel,{:PmenuExtra,}:PmenuExtraSel,x:PmenuSbar,X:PmenuThumb,*:TabLine,#:TabLineSel,_:TabLineFill,!:CursorColumn,.:CursorLine,o:ColorColumn,q:QuickFixLine,z:StatusLineTerm,Z:StatusLineTermNC,g:MsgArea,h:ComplMatchIns,%:TabPanel,^:TabPanelSel,&:TabPanelFill,I:PreInsert"
+# define HIGHLIGHT_INIT 
"8:SpecialKey,~:EndOfBuffer,@:NonText,d:Directory,e:ErrorMsg,i:IncSearch,l:Search,y:CurSearch,m:MoreMsg,M:ModeMsg,n:LineNr,a:LineNrAbove,b:LineNrBelow,N:CursorLineNr,G:CursorLineSign,O:CursorLineFold,r:Question,s:StatusLine,S:StatusLineNC,c:VertSplit,t:Title,v:Visual,V:VisualNOS,w:WarningMsg,W:WildMenu,f:Folded,F:FoldColumn,A:DiffAdd,C:DiffChange,D:DiffDelete,T:DiffText,E:DiffTextAdd,>:SignColumn,-:Conceal,B:SpellBad,P:SpellCap,R:SpellRare,L:SpellLocal,+:Pmenu,=:PmenuSel,k:PmenuMatch,<:PmenuMatchSel,[:PmenuKind,]:PmenuKindSel,{:PmenuExtra,}:PmenuExtraSel,x:PmenuSbar,X:PmenuThumb,j:PmenuBorder,H:PmenuShadow,*:TabLine,#:TabLineSel,_:TabLineFill,!:CursorColumn,.:CursorLine,o:ColorColumn,q:QuickFixLine,z:StatusLineTerm,Z:StatusLineTermNC,g:MsgArea,h:ComplMatchIns,%:TabPanel,^:TabPanelSel,&:TabPanelFill,I:PreInsert"
 
 // Default python version for pyx* commands
 #if defined(FEAT_PYTHON) && defined(FEAT_PYTHON3)
@@ -2089,6 +2089,9 @@ static struct vimoption options[] =
     {"prompt",     NULL,   P_BOOL|P_VI_DEF,
                            (char_u *)&p_prompt, PV_NONE, NULL, NULL,
                            {(char_u *)TRUE, (char_u *)0L} SCTX_INIT},
+    {"pumborder",   "pb",   P_STRING|P_VI_DEF|P_COMMA|P_NODUP|P_COLON|P_SECURE,
+                           (char_u *)&p_pb, PV_NONE, did_set_pumborder, 
expand_set_pumborder,
+                           {(char_u *)"", (char_u *)NULL} SCTX_INIT},
     {"pumheight",   "ph",   P_NUM|P_VI_DEF,
                            (char_u *)&p_ph, PV_NONE, NULL, NULL,
                            {(char_u *)0L, (char_u *)0L} SCTX_INIT},
diff --git a/src/optionstr.c b/src/optionstr.c
index 55cde5716..274e109e4 100644
--- a/src/optionstr.c
+++ b/src/optionstr.c
@@ -70,7 +70,8 @@ static char *(p_fdo_values[]) = {"all", "block", "hor", 
"mark", "percent",
 static char *(p_kpc_protocol_values[]) = {"none", "mok2", "kitty", NULL};
 #ifdef FEAT_PROP_POPUP
 // Note: Keep this in sync with parse_popup_option()
-static char *(p_popup_option_values[]) = {"height:", "width:", "highlight:", 
"border:", "align:", NULL};
+static char *(p_popup_option_values[]) = { "align:", "border:", "height:",
+    "highlight:", "shadow:", "width:", NULL};
 static char *(p_popup_option_border_values[]) = {"on", "off", NULL};
 static char *(p_popup_option_align_values[]) = {"item", "menu", NULL};
 #endif
@@ -3605,6 +3606,144 @@ expand_set_rightleftcmd(optexpand_T *args, int 
*numMatches, char_u ***matches)
 }
 #endif
 
+#define PUM_BORDER_CLEAR()   \
+    do {                     \
+       pum_set_border(FALSE); \
+       pum_set_shadow(FALSE); \
+       pum_set_margin(FALSE); \
+    } while (0)
+
+/*
+ * The 'pumborder' option is changed.
+ * Rules:
+ *   - One of { single, double, round, ascii, custom:XXXXXXXX } may appear.
+ *   - "margin" may appear, but only together with exactly one border style.
+ *   - "shadow" is independent and can be combined freely.
+ */
+    char *
+did_set_pumborder(optset_T *args)
+{
+    char_u  **varp = (char_u **)args->os_varp;
+    // Use box-drawing characters only when 'encoding' is "utf-8" and
+    // 'ambiwidth' is "single".
+    int            can_use_box_chars = (enc_utf8 && *p_ambw == 's');
+    char_u  *p, *token;
+    int            len;
+    int            have_border = FALSE;
+    int            have_margin = FALSE;
+
+    PUM_BORDER_CLEAR();
+
+    if (*varp == NULL || **varp == NUL)
+       return NULL;
+
+    for (p = *varp; p != NULL && *p != NUL; )
+    {
+       // end of token is either ',' or NUL
+       char_u *comma = vim_strchr(p, ',');
+       if (comma != NULL)
+           len = (int)(comma - p);
+       else
+           len = (int)STRLEN(p);
+
+       token = vim_strnsave(p, len);
+       if (token == NULL)
+           goto error;
+
+       if ((can_use_box_chars && (STRCMP(token, "single") == 0
+                       || STRCMP(token, "double") == 0
+                       || STRCMP(token, "round") == 0))
+               || STRCMP(token, "ascii") == 0
+               || (STRNCMP(token, "custom:", 7) == 0))
+       {
+           if (have_border)
+           {
+               // multiple border styles not allowed
+               vim_free(token);
+               goto error;
+           }
+           have_border = TRUE;
+
+           if (STRCMP(token, "single") == 0)
+               pum_set_border_chars(0x2500, 0x2502, 0x2500, 0x2502, // ─ │ ─ │
+                       0x250c, 0x2510, 0x2518, 0x2514); // ┌ ┐ ┘ └
+           else if (STRCMP(token, "double") == 0)
+               pum_set_border_chars(0x2550, 0x2551, 0x2550, 0x2551, // ═ ║ ═ ║
+                       0x2554, 0x2557, 0x255D, 0x255A); // ╔ ╗ ╝  ╚
+           else if (STRCMP(token, "round") == 0)
+               pum_set_border_chars(0x2500, 0x2502, 0x2500, 0x2502, // ─ │ ─ │
+                       0x256d, 0x256e, 0x256f, 0x2570); // ╭ ╮ ╯ ╰
+           else if (STRCMP(token, "ascii") == 0)
+               pum_set_border_chars('-', '|', '-', '|', '+', '+', '+', '+');
+           else if (STRNCMP(token, "custom:", 7) == 0)
+           {
+               char_u  *q = token + 7;
+               int     out[8];
+
+               for (int i = 0; i < 8; i++)
+               {
+                   if (*q == NUL || *q == ',')
+                       goto error;
+                   out[i] = mb_ptr2char(q);
+                   mb_ptr2char_adv(&q);
+                   if (i < 7)
+                   {
+                       if (*q != ';')
+                           goto error;  // must be semicolon
+                       q++;
+                   }
+               }
+               if (*q != NUL && *q != ',') // must end exactly after the 8th 
char
+                   goto error;
+               pum_set_border_chars(out[0], out[1], out[2], out[3], out[4], 
out[5],
+                       out[6], out[7]);
+           }
+       }
+       else if (STRCMP(token, "shadow") == 0)
+           pum_set_shadow(TRUE);
+       else if (STRCMP(token, "margin") == 0)
+       {
+           have_margin = TRUE;
+           pum_set_margin(TRUE);
+       }
+       else
+       {
+           vim_free(token);
+           goto error;
+       }
+
+       vim_free(token);
+
+       if (comma != NULL)
+           p = comma + 1; // move to next token (skip comma)
+       else
+           break;
+    }
+
+    if (have_margin && !have_border)
+       goto error; // margin must be combined with border
+
+    return NULL;
+
+error:
+    PUM_BORDER_CLEAR();
+    pum_set_border_chars(0, 0, 0, 0, 0, 0, 0, 0);
+    return e_invalid_argument;
+}
+
+    int
+expand_set_pumborder(optexpand_T *args, int *numMatches, char_u ***matches)
+{
+    static char *(p_rlc_values[]) = {"single", "double", "round", "ascii",
+       "custom", "shadow", "margin", NULL};
+    return expand_set_opt_string(
+           args,
+           p_rlc_values,
+           ARRAY_LENGTH(p_rlc_values) - 1,
+           numMatches,
+           matches);
+}
+
 #if defined(FEAT_STL_OPT) || defined(PROTO)
 /*
  * The 'rulerformat' option is changed.
diff --git a/src/po/vim.pot b/src/po/vim.pot
index 8801fc5f1..411d5ca48 100644
--- a/src/po/vim.pot
+++ b/src/po/vim.pot
@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: Vim
"
 "Report-Msgid-Bugs-To: [email protected]
"
-"POT-Creation-Date: 2025-10-06 19:09+0000
"
+"POT-Creation-Date: 2025-10-07 20:28+0000
"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE
"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>
"
 "Language-Team: LANGUAGE <[email protected]>
"
@@ -10012,6 +10012,9 @@ msgstr ""
 msgid "maximum width of the popup menu"
 msgstr ""
 
+msgid "popup border style"
+msgstr ""
+
 msgid "user defined function for Insert mode completion"
 msgstr ""
 
diff --git a/src/popupmenu.c b/src/popupmenu.c
index f13b332e4..c2fa9e725 100644
--- a/src/popupmenu.c
+++ b/src/popupmenu.c
@@ -44,10 +44,41 @@ static int pum_win_width;
 // makes pum_visible() return FALSE even when there is a popup menu.
 static int pum_pretend_not_visible = FALSE;
 
+// Border support
+static int pum_border = 0;
+static int pum_margin = 0;     // margin of 1 cell on left and right
+static int pum_shadow = 0;
+
+// Border characters
+static struct {
+    int top;
+    int right;
+    int bottom;
+    int left;
+    int top_left;
+    int top_right;
+    int bottom_right;
+    int bottom_left;
+} pum_border_chars;
+
 static int pum_set_selected(int n, int repeat);
+static void pum_draw_border(void);
+static void pum_draw_shadow(void);
+static void compute_margins(int *right_margin, int *left_margin, int 
*left_padding);
 
 #define PUM_DEF_HEIGHT 10
 
+#define DEFINE_PUM_SETTER(feature) \
+       void \
+    pum_set_##feature(int enable) \
+    { \
+       pum_##feature = enable ? 1 : 0; \
+    }
+
+DEFINE_PUM_SETTER(border)
+DEFINE_PUM_SETTER(shadow)
+DEFINE_PUM_SETTER(margin)
+
     static void
 pum_compute_size(void)
 {
@@ -92,6 +123,8 @@ pum_compute_vertical_placement(
 {
     int context_lines;
     int cline_visible_offset;
+    int extra_height = 2 * pum_border + pum_shadow;
+    int extra_offset = pum_border + pum_shadow;
 
     pum_height = MIN(size, PUM_DEF_HEIGHT);
     if (p_ph > 0 && pum_height > p_ph)
@@ -99,7 +132,7 @@ pum_compute_vertical_placement(
 
     // Put the pum below "pum_win_row" if possible.  If there are few lines
     // decide on where there is more room.
-    if (pum_win_row + 2 >= below_row - pum_height
+    if (pum_win_row + 2 >= below_row - pum_height - extra_height
            && pum_win_row - above_row > (below_row - above_row) / 2)
     {
        // pum above "pum_win_row"
@@ -110,15 +143,15 @@ pum_compute_vertical_placement(
            // Leave two lines of context if possible
            context_lines = MIN(2, curwin->w_wrow - curwin->w_cline_row);
 
-       if (pum_win_row >= size + context_lines)
+       if (pum_win_row >= size + context_lines + extra_height)
        {
-           pum_row = pum_win_row - size - context_lines;
+           pum_row = pum_win_row - size - context_lines - extra_offset;
            pum_height = size;
        }
        else
        {
-           pum_row = 0;
-           pum_height = pum_win_row - context_lines;
+           pum_row = pum_border;
+           pum_height = pum_win_row - context_lines - extra_height;
        }
        if (p_ph > 0 && pum_height > p_ph)
        {
@@ -141,8 +174,8 @@ pum_compute_vertical_placement(
            context_lines = MIN(3, cline_visible_offset);
        }
 
-       pum_row = pum_win_row + context_lines;
-       pum_height = MIN(below_row - pum_row, size);
+       pum_row = pum_win_row + context_lines + pum_border;
+       pum_height = MIN(below_row - pum_row - extra_offset, size);
        if (p_ph > 0 && pum_height > p_ph)
            pum_height = p_ph;
     }
@@ -171,7 +204,7 @@ set_pum_width_aligned_with_cursor(int width, int 
available_width)
        width = p_pw;
        end_padding = FALSE;
     }
-    if (p_pmw > 0 && width > p_pmw)
+    if (p_pmw > 0 && width >= p_pmw)
     {
        width = p_pmw;
        end_padding = FALSE;
@@ -190,16 +223,29 @@ pum_compute_horizontal_placement(int cursor_col)
 {
     int desired_width = pum_base_width + pum_kind_width + pum_extra_width;
     int available_width;
+    int col_offset;
+    int trailing_overhead = pum_scrollbar + pum_border
+       + (pum_margin && pum_border ? 1 : 0) + (pum_shadow ? 2 : 0);
 
 #ifdef FEAT_RIGHTLEFT
     if (pum_rl)
-       available_width = cursor_col - pum_scrollbar + 1;
+    {
+       col_offset = pum_border && (cursor_col >= Columns - 2)
+           ? (3 - Columns + cursor_col) : 0;
+       available_width = cursor_col + 1;
+       pum_col = cursor_col - col_offset;
+    }
     else
 #endif
-       available_width = Columns - cursor_col - pum_scrollbar;
+    {
+       col_offset = pum_border && (cursor_col <= 1) ? (2 - cursor_col) : 0;
+       available_width = Columns - cursor_col;
+       pum_col = cursor_col + col_offset;
+    }
+
+    available_width -= trailing_overhead + col_offset;
 
-    // Align pum with "cursor_col"
-    pum_col = cursor_col;
+    // Case 1: Align pum with "cursor_col"
     if (set_pum_width_aligned_with_cursor(desired_width, available_width))
        return;
     // Show the pum truncated, provided it is at least as wide as 'pum_width'
@@ -209,34 +255,29 @@ pum_compute_horizontal_placement(int cursor_col)
        return;
     }
 
-    // Truncated pum is no longer aligned with "cursor_col"
-#ifdef FEAT_RIGHTLEFT
-    if (pum_rl)
-       available_width = Columns - pum_scrollbar;
-    else
-#endif
-       available_width += cursor_col;
+    // Case 2: Truncated pum is no longer aligned with "cursor_col"
+    available_width = Columns - trailing_overhead - col_offset;
 
     if (available_width > p_pw)
     {
-       pum_width = p_pw + 1;  // Truncate beyond 'pum_width'
+       pum_width = p_pw;  // Truncate beyond 'pum_width'
 #ifdef FEAT_RIGHTLEFT
        if (pum_rl)
-           pum_col = pum_width + pum_scrollbar;
+           pum_col = pum_width + trailing_overhead;
        else
 #endif
-           pum_col = Columns - pum_width - pum_scrollbar;
+           pum_col = Columns - pum_width - trailing_overhead;
        return;
     }
 
-    // Not enough room anywhere, use what we have
+    // Case 3: Not enough room anywhere, use what we have
 #ifdef FEAT_RIGHTLEFT
     if (pum_rl)
-       pum_col = Columns - 1;
+       pum_col = Columns - 1 - col_offset;
     else
 #endif
-       pum_col = 0;
-    pum_width = Columns - pum_scrollbar;
+       pum_col = col_offset;
+    pum_width = Columns - trailing_overhead;
 }
 
 /*
@@ -568,7 +609,7 @@ pum_display_rtl_text(
 
     char_u *rt_start = rt;
     cells = mb_string2cells(rt, -1);
-    truncated = width_limit - totwidth - 1 < cells + pad;
+    truncated = width_limit - totwidth < cells + pad;
 
     // only draw the text that fits
     if (cells > width_limit)
@@ -664,7 +705,7 @@ pum_display_ltr_text(
 
     size = (int)STRLEN(st);
     cells = (*mb_string2cells)(st, size);
-    truncated = width_limit - totwidth - 1 < cells + pad;
+    truncated = width_limit - totwidth < cells + pad;
 
     // only draw the text that fits
     while (size > 0 && col + cells > width_limit + pum_col)
@@ -905,6 +946,12 @@ pum_redraw(void)
     screen_zindex = POPUPMENU_ZINDEX;
 #endif
 
+    // Draw border and shadow first if enabled
+    if (pum_border)
+       pum_draw_border();
+    if (pum_shadow)
+       pum_draw_shadow();
+
     for (i = 0; i < pum_height; ++i)
     {
        idx = i + pum_first;
@@ -916,12 +963,12 @@ pum_redraw(void)
 #ifdef FEAT_RIGHTLEFT
        if (pum_rl)
        {
-           if (pum_col < curwin->w_wincol + curwin->w_width - 1)
+           if (pum_col < curwin->w_wincol + curwin->w_width - 1 - pum_border)
                screen_putchar(' ', row, pum_col + 1, attr);
        }
        else
 #endif
-           if (pum_col > 0)
+           if (pum_col > pum_border)
                screen_putchar(' ', row, pum_col - 1, attr);
 
        // Display each entry, use two spaces for a Tab.
@@ -1008,14 +1055,22 @@ pum_position_info_popup(win_T *wp)
     int row = pum_row;
     int botpos = POPPOS_BOTLEFT;
     int        used_maxwidth_opt = FALSE;
+    int        right_margin, left_margin, dummy;
+    int left_extra_width, right_extra_width;
+
+    (void)compute_margins(&right_margin, &left_margin, &dummy);
+
+    left_extra_width = pum_border + left_margin;
+    right_extra_width = pum_border + right_margin + (pum_shadow ? 2 : 0);
+    col += right_extra_width;
 
     wp->w_popup_pos = POPPOS_TOPLEFT;
     if (Columns - col < 20 && Columns - col < pum_col)
     {
-       col = pum_col - 1;
+       col = pum_col - 1 - left_extra_width;
        wp->w_popup_pos = POPPOS_TOPRIGHT;
        botpos = POPPOS_BOTRIGHT;
-       wp->w_maxwidth = pum_col - 1;
+       wp->w_maxwidth = pum_col - 1 - left_extra_width;
     }
     else
        wp->w_maxwidth = Columns - col + 1;
@@ -1495,50 +1550,63 @@ pum_set_event_info(dict_T *dict)
     static void
 pum_position_at_mouse(int min_width)
 {
-    if (Rows - mouse_row > pum_size || Rows - mouse_row > mouse_row)
+    int extra_height = pum_border * 2 + pum_shadow;
+    int extra_offset = pum_border + pum_shadow;
+    int trailing_overhead = 0;
+    int col_offset = 0;
+    int available_width;
+
+    if (Rows - mouse_row - extra_height > pum_size
+           || Rows - mouse_row > mouse_row)
     {
        // Enough space below the mouse row,
        // or there is more space below the mouse row than above.
-       pum_row = mouse_row + 1;
-       if (pum_height > Rows - pum_row)
-           pum_height = Rows - pum_row;
-       if (pum_row + pum_height > cmdline_row)
+       pum_row = mouse_row + 1 + pum_border;
+       if (pum_height > Rows - pum_row - extra_height)
+           pum_height = Rows - pum_row - extra_height;
+       if (pum_row + pum_height + extra_offset >= cmdline_row)
            pum_in_cmdline = TRUE;
     }
     else
     {
        // Show above the mouse row, reduce height if it does not fit.
-       pum_row = mouse_row - pum_size;
-       if (pum_row < 0)
+       pum_row = mouse_row - pum_size - extra_offset;
+       if (pum_row < pum_border)
        {
-           pum_height += pum_row;
-           pum_row = 0;
+           pum_height += pum_row - pum_border;
+           pum_row = pum_border;
        }
     }
 
+    trailing_overhead = pum_scrollbar + pum_border
+       + (pum_margin && pum_border ? 1 : 0) + (pum_shadow ? 2 : 0);
+
 # ifdef FEAT_RIGHTLEFT
     if (pum_rl)
     {
-       if (mouse_col + 1 >= pum_base_width
-               || mouse_col + 1 > min_width)
+       col_offset = (mouse_col == Columns - 1) && pum_border;
+       available_width = mouse_col + 1 - trailing_overhead - col_offset;
+       if (available_width >= pum_base_width || available_width > min_width)
            // Enough space to show at mouse column.
-           pum_col = mouse_col;
+           pum_col = mouse_col - col_offset;
        else
            // Not enough space, left align with window.
-           pum_col = MIN(pum_base_width, min_width) - 1;
-       pum_width = pum_col + 1;
+           pum_col = MIN(pum_base_width, min_width) - 1 + trailing_overhead;
+       pum_width = pum_col + 1 - trailing_overhead;
     }
     else
 # endif
     {
-       if (Columns - mouse_col >= pum_base_width
-               || Columns - mouse_col > min_width)
+       col_offset = (mouse_col == 0) && pum_border;
+       available_width = Columns - mouse_col - trailing_overhead - col_offset;
+       if (available_width >= pum_base_width || available_width > min_width)
            // Enough space to show at mouse column.
-           pum_col = mouse_col;
+           pum_col = mouse_col + col_offset;
        else
            // Not enough space, right align with window.
-           pum_col = Columns -  MIN(pum_base_width, min_width);
-       pum_width = Columns - pum_col;
+           pum_col = Columns - MIN(pum_base_width, min_width)
+               - trailing_overhead;
+       pum_width = Columns - pum_col - trailing_overhead;
     }
 
     pum_width = MIN(pum_width, pum_base_width + 1);
@@ -1985,3 +2053,250 @@ pum_make_popup(char_u *path_name, int use_mouse_pos)
        pum_show_popupmenu(menu);
 }
 #endif
+
+    static int
+is_singlewidth(int c)
+{
+    if (c >= 0 && c < 0x80)
+       return TRUE;
+    if (utf_char2cells(c) == 1)
+       return TRUE;
+    return FALSE;
+}
+
+/*
+ * Set border characters for popup menu.
+ */
+    void
+pum_set_border_chars(
+       int top,
+       int right,
+       int bottom,
+       int left,
+       int top_left,
+       int top_right,
+       int bottom_right,
+       int bottom_left)
+{
+    if (!is_singlewidth(top) || !is_singlewidth(right)
+           || !is_singlewidth(bottom) || !is_singlewidth(left)
+           || !is_singlewidth(top_left) || !is_singlewidth(top_right)
+           || !is_singlewidth(bottom_right) || !is_singlewidth(bottom_left))
+       return;
+    pum_border_chars.top = top;
+    pum_border_chars.right = right;
+    pum_border_chars.bottom = bottom;
+    pum_border_chars.left = left;
+    pum_border_chars.top_left = top_left;
+    pum_border_chars.top_right = top_right;
+    pum_border_chars.bottom_right = bottom_right;
+    pum_border_chars.bottom_left = bottom_left;
+    pum_border = 1;
+}
+
+/*
+ * Compute margins for the popup menu.
+ */
+    static void
+compute_margins(int *right_margin, int *left_margin, int *left_padding)
+{
+    *right_margin = pum_margin && pum_border;
+
+#ifdef FEAT_RIGHTLEFT
+    if (pum_rl)
+    {
+       *left_padding = (pum_col < Columns - 1 - pum_border);
+       *left_margin = *right_margin && (pum_col < Columns - 3);
+       return;
+    }
+#endif
+    *left_padding = (pum_col > pum_border);
+    *left_margin = *right_margin && (pum_col > 2);
+}
+
+/*
+ * Draw the border around the popup menu
+ */
+    static void
+pum_draw_border(void)
+{
+    int        top_row = pum_row - 1;
+    int        bottom_row = pum_row + pum_height;
+    int        col;
+    int        attr = highlight_attr[HLF_PMB];
+    int        right_margin, left_margin, left_padding;
+    int        inner_width;
+
+    if (!pum_border)
+       return;
+
+    (void)compute_margins(&right_margin, &left_margin, &left_padding);
+
+    inner_width = pum_width + pum_scrollbar + left_padding;
+
+    // Draw border left to right or right to left (for RTL)
+#ifdef FEAT_RIGHTLEFT
+    if (pum_rl)
+       col = pum_col + left_padding + 1;
+    else
+#endif
+       col = pum_col - left_padding - 1;
+
+    // left corners (right corners for RTL)
+#ifdef FEAT_RIGHTLEFT
+    if (pum_rl)
+    {
+       screen_putchar(pum_border_chars.top_right, top_row, col, attr);
+       if (left_margin)
+           screen_putchar(' ', top_row, col + 1, attr);
+       screen_putchar(pum_border_chars.bottom_right, bottom_row, col, attr);
+       if (left_margin)
+           screen_putchar(' ', bottom_row, col + 1, attr);
+    }
+    else
+#endif
+    {
+       screen_putchar(pum_border_chars.top_left, top_row, col, attr);
+       if (left_margin)
+           screen_putchar(' ', top_row, col - 1, attr);
+       screen_putchar(pum_border_chars.bottom_left, bottom_row, col, attr);
+       if (left_margin)
+           screen_putchar(' ', bottom_row, col - 1, attr);
+    }
+
+    // Top horizontal lines
+    for (int i = 0; i < inner_width; i++)
+    {
+       int cur_col;
+#ifdef FEAT_RIGHTLEFT
+       if (pum_rl)
+           cur_col = col - 1 - i;
+       else
+#endif
+           cur_col = col + 1 + i;
+       screen_putchar(pum_border_chars.top, top_row, cur_col, attr);
+       screen_putchar(pum_border_chars.bottom, bottom_row, cur_col, attr);
+    }
+
+    // right corners (left corners for RTL)
+#ifdef FEAT_RIGHTLEFT
+    if (pum_rl)
+    {
+       screen_putchar(pum_border_chars.top_left, top_row,
+               col - inner_width - 1, attr);
+       if (right_margin)
+           screen_putchar(' ', top_row, col - inner_width - 2, attr);
+       screen_putchar(pum_border_chars.bottom_left, bottom_row,
+               col - inner_width - 1, attr);
+       if (right_margin)
+           screen_putchar(' ', bottom_row, col - inner_width - 2, attr);
+    }
+    else
+#endif
+    {
+       screen_putchar(pum_border_chars.top_right, top_row,
+               col + inner_width + 1, attr);
+       if (right_margin)
+           screen_putchar(' ', top_row, col + inner_width + 2, attr);
+       screen_putchar(pum_border_chars.bottom_right, bottom_row,
+               col + inner_width + 1, attr);
+       if (right_margin)
+           screen_putchar(' ', bottom_row, col + inner_width + 2, attr);
+    }
+
+    // Draw side borders
+    for (int i = 0; i < pum_height; i++)
+    {
+       int row = pum_row + i;
+#ifdef FEAT_RIGHTLEFT
+       if (pum_rl)
+       {
+           screen_putchar(pum_border_chars.left, row, col, attr);
+           if (left_margin)
+               screen_putchar(' ', row, col + 1, attr);
+           screen_putchar(pum_border_chars.right, row,
+                   col - inner_width - 1, attr);
+           if (right_margin)
+               screen_putchar(' ', row, col - inner_width - 2, attr);
+       }
+       else
+#endif
+       {
+           screen_putchar(pum_border_chars.left, row, col, attr);
+           if (left_margin)
+               screen_putchar(' ', row, col - 1, attr);
+           screen_putchar(pum_border_chars.right, row,
+                   col + inner_width + 1, attr);
+           if (right_margin)
+               screen_putchar(' ', row, col + inner_width + 2, attr);
+       }
+    }
+}
+
+/*
+ * Get the underlying character and redraw with shadow highlight
+ */
+    void
+put_shadow_char(int row, int col)
+{
+    char_u  buf[MB_MAXBYTES + 1];
+    int            attr = highlight_attr[HLF_PMS];
+
+    screen_getbytes(row, col, buf, NULL);
+    screen_putchar((*mb_ptr2char)(buf), row, col, attr);
+}
+
+/*
+ * Draw the shadow
+ */
+    static void
+pum_draw_shadow(void)
+{
+    int        row, col, next_col;
+    int        width, offset;
+    int        inner_width;
+    int        right_margin, left_margin, left_padding;
+
+    if (!pum_shadow)
+       return;
+
+    (void)compute_margins(&right_margin, &left_margin, &left_padding);
+    inner_width = pum_width + pum_scrollbar + pum_border + right_margin;
+
+    // Draw right side shadow (left for RTL)
+#ifdef FEAT_RIGHTLEFT
+    if (pum_rl)
+    {
+       col = pum_col - inner_width;
+       next_col = col - 1;
+    }
+    else
+#endif
+    {
+       col = pum_col + inner_width;
+       next_col = col + 1;
+    }
+
+    for (int i = 0; i < pum_height + pum_border; i++)
+    {
+       row = pum_row + 1 + i - pum_border;
+       put_shadow_char(row, col);
+       put_shadow_char(row, next_col);
+    }
+
+    // Bottom shadow
+    row = pum_row + pum_height + pum_border;
+    width = inner_width + left_padding + pum_border + left_margin;
+    offset = 2 - left_padding - pum_border - left_margin;
+
+    for (int i = 0; i < width; i++)
+    {
+#ifdef FEAT_RIGHTLEFT
+       if (pum_rl)
+           col = pum_col - offset - i;
+       else
+#endif
+           col = pum_col + offset + i;
+       put_shadow_char(row, col);
+    }
+}
diff --git a/src/proto/optionstr.pro b/src/proto/optionstr.pro
index 734959b60..b3ee0f8b2 100644
--- a/src/proto/optionstr.pro
+++ b/src/proto/optionstr.pro
@@ -209,4 +209,6 @@ int check_ff_value(char_u *p);
 void save_clear_shm_value(void);
 void restore_shm_value(void);
 void export_myvimdir(void);
+char *did_set_pumborder(optset_T *args);
+int expand_set_pumborder(optexpand_T *args, int *numMatches, char_u 
***matches);
 /* vim: set ft=c : */
diff --git a/src/proto/popupmenu.pro b/src/proto/popupmenu.pro
index 53ef843c1..b689f6fb3 100644
--- a/src/proto/popupmenu.pro
+++ b/src/proto/popupmenu.pro
@@ -17,4 +17,9 @@ void ui_post_balloon(char_u *mesg, list_T *list);
 void ui_may_remove_balloon(void);
 void pum_show_popupmenu(vimmenu_T *menu);
 void pum_make_popup(char_u *path_name, int use_mouse_pos);
+void pum_set_border_chars(int top, int right, int bottom, int left, int 
top_left, int top_right, int bottom_right, int bottom_left);
+void pum_set_border(int enable);
+void pum_set_shadow(int enable);
+void pum_set_margin(int enable);
+void put_shadow_char(int row, int col);
 /* vim: set ft=c : */
diff --git a/src/testdir/dumps/Test_mouse_popup_position_01.dump 
b/src/testdir/dumps/Test_mouse_popup_position_01.dump
index 8e936045f..54ba886c9 100644
--- a/src/testdir/dumps/Test_mouse_popup_position_01.dump
+++ b/src/testdir/dumps/Test_mouse_popup_position_01.dump
@@ -5,7 +5,7 @@
 |~+0#4040ff13#ffffff0| @31| +0#0000001#ffd7ff255@16
 |~+0#4040ff13#ffffff0| @31| +0#0000001#ffd7ff255|S|e|l|e|c|t| |W|o|r|d| @4
 |~+0#4040ff13#ffffff0| @31| +0#0000001#ffd7ff255|S|e|l|e|c|t| 
|S|e|n|t|e|n|c|e| 
-|~+0#4040ff13#ffffff0| @31| +0#0000001#ffd7ff255|S|e|l|e|c|t| 
|P|a|r|a|g|r|a|p|>
+|~+0#4040ff13#ffffff0| @31| +0#0000001#ffd7ff255|S|e|l|e|c|t| 
|P|a|r|a|g|r|a|p|h
 |~+0#4040ff13#ffffff0| @31| +0#0000001#ffd7ff255|S|e|l|e|c|t| |L|i|n|e| @4
 |~+0#4040ff13#ffffff0| @31| +0#0000001#ffd7ff255|S|e|l|e|c|t| |B|l|o|c|k| @3
 |~+0#4040ff13#ffffff0| @31| +0#0000001#ffd7ff255|S|e|l|e|c|t| |A|l@1| @5
diff --git a/src/testdir/dumps/Test_mouse_popup_position_02.dump 
b/src/testdir/dumps/Test_mouse_popup_position_02.dump
index babd58702..e70cd08d5 100644
--- a/src/testdir/dumps/Test_mouse_popup_position_02.dump
+++ b/src/testdir/dumps/Test_mouse_popup_position_02.dump
@@ -1,20 +1,20 @@
-| +0&#ffffff0|9|1| |8>1| |7|1| |6|1| |5|1| |4|1| |3|1| |2|1| |1@1| |0|1| |9| 
|8| |7| |6| |5| |4| |3| |2| |1| |0
-| +0#0000001#ffd7ff255@11|o|d|n|U| | +0#4040ff13#ffffff0@31|~
-| +0#0000001#ffd7ff255@16| +0#4040ff13#ffffff0@31|~
-| +0#0000001#ffd7ff255@10|e|t|s|a|P| | +0#4040ff13#ffffff0@31|~
-| +0#0000001#ffd7ff255@16| +0#4040ff13#ffffff0@31|~
-| +0#0000001#ffd7ff255@4|d|r|o|W| |t|c|e|l|e|S| | +0#4040ff13#ffffff0@31|~
-| +0#0000001#ffd7ff255|e|c|n|e|t|n|e|S| |t|c|e|l|e|S| | 
+0#4040ff13#ffffff0@31|~
-|<+0#0000001#ffd7ff255|p|a|r|g|a|r|a|P| |t|c|e|l|e|S| | 
+0#4040ff13#ffffff0@31|~
-| +0#0000001#ffd7ff255@4|e|n|i|L| |t|c|e|l|e|S| | +0#4040ff13#ffffff0@31|~
-| +0#0000001#ffd7ff255@3|k|c|o|l|B| |t|c|e|l|e|S| | +0#4040ff13#ffffff0@31|~
-| +0#0000001#ffd7ff255@5|l@1|A| |t|c|e|l|e|S| | +0#4040ff13#ffffff0@31|~
-| @48|~
-| @48|~
-| @48|~
-| @48|~
-| @48|~
-| @48|~
-| @48|~
-| @48|~
-|:+0#0000000&|c|a|l@1| |T|r|i|g@1|e|r|(|5|0| |+| |1| |-| |4|5|)| @5|1|,|4|5| 
@9|A|l@1| 
+|0+0&#ffffff0| |1| |2| |3| |4| |5| |6| |7| |8| |9| |1|0| |1@1| |1|2| |1|3| 
|1|4| |1|5| |1|6| |1|7| >1|8| |1|9| 
+|~+0#4040ff13&| @25| +0#0000001#ffd7ff255|╔|═@16|╗| | +0#4040ff13#ffffff0@1
+|~| @25| +0#0000001#ffd7ff255|║| |U|n|d|o| @11|║| | +0#6c6c6c255#0000001@1
+|~+0#4040ff13#ffffff0| @25| +0#0000001#ffd7ff255|║| @16|║| | 
+0#6c6c6c255#0000001@1
+|~+0#4040ff13#ffffff0| @25| +0#0000001#ffd7ff255|║| |P|a|s|t|e| @10|║| | 
+0#6c6c6c255#0000001@1
+|~+0#4040ff13#ffffff0| @25| +0#0000001#ffd7ff255|║| @16|║| | 
+0#6c6c6c255#0000001@1
+|~+0#4040ff13#ffffff0| @25| +0#0000001#ffd7ff255|║| |S|e|l|e|c|t| |W|o|r|d| 
@4|║| | +0#6c6c6c255#0000001@1
+|~+0#4040ff13#ffffff0| @25| +0#0000001#ffd7ff255|║| |S|e|l|e|c|t| 
|S|e|n|t|e|n|c|e| |║| | +0#6c6c6c255#0000001@1
+|~+0#4040ff13#ffffff0| @25| +0#0000001#ffd7ff255|║| |S|e|l|e|c|t| 
|P|a|r|a|g|r|a|p|h|║| | +0#6c6c6c255#0000001@1
+|~+0#4040ff13#ffffff0| @25| +0#0000001#ffd7ff255|║| |S|e|l|e|c|t| |L|i|n|e| 
@4|║| | +0#6c6c6c255#0000001@1
+|~+0#4040ff13#ffffff0| @25| +0#0000001#ffd7ff255|║| |S|e|l|e|c|t| |B|l|o|c|k| 
@3|║| | +0#6c6c6c255#0000001@1
+|~+0#4040ff13#ffffff0| @25| +0#0000001#ffd7ff255|║| |S|e|l|e|c|t| |A|l@1| 
@5|║| | +0#6c6c6c255#0000001@1
+|~+0#4040ff13#ffffff0| @25| +0#0000001#ffd7ff255|╚|═@16|╝| | 
+0#6c6c6c255#0000001@1
+|~+0#4040ff13#ffffff0| @27| +0#6c6c6c255#0000001@20
+|~+0#4040ff13#ffffff0| @48
+|~| @48
+|~| @48
+|~| @48
+|~| @48
+|:+0#0000000&|c|a|l@1| |T|r|i|g@1|e|r|(|4|5|)| @14|1|,|4|5| @9|A|l@1| 
diff --git a/src/testdir/dumps/Test_mouse_popup_position_03.dump 
b/src/testdir/dumps/Test_mouse_popup_position_03.dump
new file mode 100644
index 000000000..7dfab529e
--- /dev/null
+++ b/src/testdir/dumps/Test_mouse_popup_position_03.dump
@@ -0,0 +1,20 @@
+| +0&#ffffff0|9|1| |8>1| |7|1| |6|1| |5|1| |4|1| |3|1| |2|1| |1@1| |0|1| |9| 
|8| |7| |6| |5| |4| |3| |2| |1| |0
+| +0#0000001#ffd7ff255@11|o|d|n|U| | +0#4040ff13#ffffff0@31|~
+| +0#0000001#ffd7ff255@16| +0#4040ff13#ffffff0@31|~
+| +0#0000001#ffd7ff255@10|e|t|s|a|P| | +0#4040ff13#ffffff0@31|~
+| +0#0000001#ffd7ff255@16| +0#4040ff13#ffffff0@31|~
+| +0#0000001#ffd7ff255@4|d|r|o|W| |t|c|e|l|e|S| | +0#4040ff13#ffffff0@31|~
+| +0#0000001#ffd7ff255|e|c|n|e|t|n|e|S| |t|c|e|l|e|S| | 
+0#4040ff13#ffffff0@31|~
+|h+0#0000001#ffd7ff255|p|a|r|g|a|r|a|P| |t|c|e|l|e|S| | 
+0#4040ff13#ffffff0@31|~
+| +0#0000001#ffd7ff255@4|e|n|i|L| |t|c|e|l|e|S| | +0#4040ff13#ffffff0@31|~
+| +0#0000001#ffd7ff255@3|k|c|o|l|B| |t|c|e|l|e|S| | +0#4040ff13#ffffff0@31|~
+| +0#0000001#ffd7ff255@5|l@1|A| |t|c|e|l|e|S| | +0#4040ff13#ffffff0@31|~
+| @48|~
+| @48|~
+| @48|~
+| @48|~
+| @48|~
+| @48|~
+| @48|~
+| @48|~
+|:+0#0000000&|c|a|l@1| |T|r|i|g@1|e|r|(|5|0| |+| |1| |-| |4|5|)| @5|1|,|4|5| 
@9|A|l@1| 
diff --git a/src/testdir/dumps/Test_mouse_popup_position_04.dump 
b/src/testdir/dumps/Test_mouse_popup_position_04.dump
new file mode 100644
index 000000000..7dfab529e
--- /dev/null
+++ b/src/testdir/dumps/Test_mouse_popup_position_04.dump
@@ -0,0 +1,20 @@
+| +0&#ffffff0|9|1| |8>1| |7|1| |6|1| |5|1| |4|1| |3|1| |2|1| |1@1| |0|1| |9| 
|8| |7| |6| |5| |4| |3| |2| |1| |0
+| +0#0000001#ffd7ff255@11|o|d|n|U| | +0#4040ff13#ffffff0@31|~
+| +0#0000001#ffd7ff255@16| +0#4040ff13#ffffff0@31|~
+| +0#0000001#ffd7ff255@10|e|t|s|a|P| | +0#4040ff13#ffffff0@31|~
+| +0#0000001#ffd7ff255@16| +0#4040ff13#ffffff0@31|~
+| +0#0000001#ffd7ff255@4|d|r|o|W| |t|c|e|l|e|S| | +0#4040ff13#ffffff0@31|~
+| +0#0000001#ffd7ff255|e|c|n|e|t|n|e|S| |t|c|e|l|e|S| | 
+0#4040ff13#ffffff0@31|~
+|h+0#0000001#ffd7ff255|p|a|r|g|a|r|a|P| |t|c|e|l|e|S| | 
+0#4040ff13#ffffff0@31|~
+| +0#0000001#ffd7ff255@4|e|n|i|L| |t|c|e|l|e|S| | +0#4040ff13#ffffff0@31|~
+| +0#0000001#ffd7ff255@3|k|c|o|l|B| |t|c|e|l|e|S| | +0#4040ff13#ffffff0@31|~
+| +0#0000001#ffd7ff255@5|l@1|A| |t|c|e|l|e|S| | +0#4040ff13#ffffff0@31|~
+| @48|~
+| @48|~
+| @48|~
+| @48|~
+| @48|~
+| @48|~
+| @48|~
+| @48|~
+|:+0#0000000&|c|a|l@1| |T|r|i|g@1|e|r|(|5|0| |+| |1| |-| |4|5|)| @5|1|,|4|5| 
@9|A|l@1| 
diff --git a/src/testdir/dumps/Test_popup_border_end_20.dump 
b/src/testdir/dumps/Test_popup_border_end_20.dump
new file mode 100644
index 000000000..f37ecbb53
--- /dev/null
+++ b/src/testdir/dumps/Test_popup_border_end_20.dump
@@ -0,0 +1,8 @@
+|1+0&#ffffff0|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a| 
@5||+1&&|1+0&&|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a| @5
+|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b| 
@5||+1&&|1+0&&|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b| @5
+@20|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7||+1&&| 
+0&&@19|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7
+|8|9|_|1|2|3|4|5|6|7|8|9|_|a| @22||+1&&|8+0&&|9|_|1|2|3|4|5|6|7|8|9|_|a> @22
+|~+0#4040ff13&| @35||+1#0000000&|~+0#4040ff13&| 
@16|╔+0#0000001#ffd7ff255|═@16|╗
+|~+0#4040ff13#ffffff0| @35||+1#0000000&|~+0#4040ff13&| 
@16|║+0#0000001#ffd7ff255| 
+0&#e0e0e08|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|>|║+0&#ffd7ff255
+|~+0#4040ff13#ffffff0| @35||+1#0000000&|~+0#4040ff13&| 
@16|║+0#0000001#ffd7ff255| |1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|>|║
+|~+0#4040ff13#ffffff0| @35||+1#0000000&|~+0#4040ff13&| 
@16|╚+0#0000001#ffd7ff255|═@16|╝
diff --git a/src/testdir/dumps/Test_popup_border_end_21.dump 
b/src/testdir/dumps/Test_popup_border_end_21.dump
new file mode 100644
index 000000000..eb1fa0af2
--- /dev/null
+++ b/src/testdir/dumps/Test_popup_border_end_21.dump
@@ -0,0 +1,8 @@
+|1+0&#ffffff0|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a| 
@5||+1&&|1+0&&|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a| @5
+|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b| 
@5||+1&&|1+0&&|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b| @5
+@21|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6||+1&&| 
+0&&@20|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6
+|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a| @21||+1&&|7+0&&|8|9|_|1|2|3|4|5|6|7|8|9|_|a> 
@21
+|~+0#4040ff13&| @35||+1#0000000&|~+0#4040ff13&| 
@17|╔+0#0000001#ffd7ff255|═@15|╗
+|~+0#4040ff13#ffffff0| @35||+1#0000000&|~+0#4040ff13&| 
@17|║+0#0000001#ffd7ff255| 
+0&#e0e0e08|1|2|3|4|5|6|7|8|9|_|1|2|3|4|>|║+0&#ffd7ff255
+|~+0#4040ff13#ffffff0| @35||+1#0000000&|~+0#4040ff13&| 
@17|║+0#0000001#ffd7ff255| |1|2|3|4|5|6|7|8|9|_|1|2|3|4|>|║
+|~+0#4040ff13#ffffff0| @35||+1#0000000&|~+0#4040ff13&| 
@17|╚+0#0000001#ffd7ff255|═@15|╝
diff --git a/src/testdir/dumps/Test_popup_border_end_22.dump 
b/src/testdir/dumps/Test_popup_border_end_22.dump
new file mode 100644
index 000000000..153bcac69
--- /dev/null
+++ b/src/testdir/dumps/Test_popup_border_end_22.dump
@@ -0,0 +1,8 @@
+|1+0&#ffffff0|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a| 
@5||+1&&|1+0&&|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a| @5
+|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b| 
@5||+1&&|1+0&&|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b| @5
+@22|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5||+1&&| +0&&@21|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5
+|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a| 
@20||+1&&|6+0&&|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a> @20
+|~+0#4040ff13&| @35||+1#0000000&|~+0#4040ff13&| 
@17|╔+0#0000001#ffd7ff255|═@15|╗
+|~+0#4040ff13#ffffff0| @35||+1#0000000&|~+0#4040ff13&| 
@17|║+0#0000001#ffd7ff255| 
+0&#e0e0e08|1|2|3|4|5|6|7|8|9|_|1|2|3|4|>|║+0&#ffd7ff255
+|~+0#4040ff13#ffffff0| @35||+1#0000000&|~+0#4040ff13&| 
@17|║+0#0000001#ffd7ff255| |1|2|3|4|5|6|7|8|9|_|1|2|3|4|>|║
+|~+0#4040ff13#ffffff0| @35||+1#0000000&|~+0#4040ff13&| 
@17|╚+0#0000001#ffd7ff255|═@15|╝
diff --git a/src/testdir/dumps/Test_popup_border_end_5.dump 
b/src/testdir/dumps/Test_popup_border_end_5.dump
new file mode 100644
index 000000000..4e47ef110
--- /dev/null
+++ b/src/testdir/dumps/Test_popup_border_end_5.dump
@@ -0,0 +1,8 @@
+|1+0&#ffffff0|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a| 
@5||+1&&|1+0&&|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a| @5
+|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b| 
@5||+1&&|1+0&&|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b| @5
+@5|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a| ||+1&&| 
+0&&@4|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a> 
+|~+0#4040ff13&| @35||+1#0000000&|~+0#4040ff13&| @1|╔+0#0000001#ffd7ff255|═@31|╗
+|~+0#4040ff13#ffffff0| @35||+1#0000000&|~+0#4040ff13&| 
@1|║+0#0000001#ffd7ff255| 
+0&#e0e0e08|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a|║+0&#ffd7ff255
+|~+0#4040ff13#ffffff0| @35||+1#0000000&|~+0#4040ff13&| 
@1|║+0#0000001#ffd7ff255| 
|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b|║
+|~+0#4040ff13#ffffff0| @35||+1#0000000&|~+0#4040ff13&| 
@1|╚+0#0000001#ffd7ff255|═@31|╝
+|~+0#4040ff13#ffffff0| @35||+1#0000000&|~+0#4040ff13&| @35
diff --git a/src/testdir/dumps/Test_popup_border_end_6.dump 
b/src/testdir/dumps/Test_popup_border_end_6.dump
new file mode 100644
index 000000000..d5891f708
--- /dev/null
+++ b/src/testdir/dumps/Test_popup_border_end_6.dump
@@ -0,0 +1,8 @@
+|1+0&#ffffff0|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a| 
@5||+1&&|1+0&&|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a| @5
+|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b| 
@5||+1&&|1+0&&|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b| @5
+@6|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a||+1&&| 
+0&&@5|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a
+|~+0#4040ff13&| @35||+1#0000000&>~+0#4040ff13&| @2|╔+0#0000001#ffd7ff255|═@30|╗
+|~+0#4040ff13#ffffff0| @35||+1#0000000&|~+0#4040ff13&| 
@2|║+0#0000001#ffd7ff255| 
+0&#e0e0e08|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|>|║+0&#ffd7ff255
+|~+0#4040ff13#ffffff0| @35||+1#0000000&|~+0#4040ff13&| 
@2|║+0#0000001#ffd7ff255| 
|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|>|║
+|~+0#4040ff13#ffffff0| @35||+1#0000000&|~+0#4040ff13&| 
@2|╚+0#0000001#ffd7ff255|═@30|╝
+|~+0#4040ff13#ffffff0| @35||+1#0000000&|~+0#4040ff13&| @35
diff --git a/src/testdir/dumps/Test_popup_border_end_m_19.dump 
b/src/testdir/dumps/Test_popup_border_end_m_19.dump
new file mode 100644
index 000000000..ae783607d
--- /dev/null
+++ b/src/testdir/dumps/Test_popup_border_end_m_19.dump
@@ -0,0 +1,8 @@
+|1+0&#ffffff0|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a| 
@5||+1&&|1+0&&|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a| @5
+|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b| 
@5||+1&&|1+0&&|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b| @5
+@19|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8||+1&&| 
+0&&@18|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8
+|9|_|1|2|3|4|5|6|7|8|9|_|a| @23||+1&&|9+0&&|_|1|2|3|4|5|6|7|8|9|_|a> @23
+|~+0#4040ff13&| @35||+1#0000000&|~+0#4040ff13&| @14| 
+0#0000001#ffd7ff255|╔|═@16|╗| 
+|~+0#4040ff13#ffffff0| @35||+1#0000000&|~+0#4040ff13&| @14| 
+0#0000001#ffd7ff255|║| 
+0&#e0e0e08|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|>|║+0&#ffd7ff255| 
+|~+0#4040ff13#ffffff0| @35||+1#0000000&|~+0#4040ff13&| @14| 
+0#0000001#ffd7ff255|║| |1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|>|║| 
+|~+0#4040ff13#ffffff0| @35||+1#0000000&|~+0#4040ff13&| @14| 
+0#0000001#ffd7ff255|╚|═@16|╝| 
diff --git a/src/testdir/dumps/Test_popup_border_end_m_20.dump 
b/src/testdir/dumps/Test_popup_border_end_m_20.dump
new file mode 100644
index 000000000..00b72d238
--- /dev/null
+++ b/src/testdir/dumps/Test_popup_border_end_m_20.dump
@@ -0,0 +1,8 @@
+|1+0&#ffffff0|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a| 
@5||+1&&|1+0&&|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a| @5
+|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b| 
@5||+1&&|1+0&&|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b| @5
+@20|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7||+1&&| 
+0&&@19|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7
+|8|9|_|1|2|3|4|5|6|7|8|9|_|a| @22||+1&&|8+0&&|9|_|1|2|3|4|5|6|7|8|9|_|a> @22
+|~+0#4040ff13&| @35||+1#0000000&|~+0#4040ff13&| @15| 
+0#0000001#ffd7ff255|╔|═@15|╗| 
+|~+0#4040ff13#ffffff0| @35||+1#0000000&|~+0#4040ff13&| @15| 
+0#0000001#ffd7ff255|║| 
+0&#e0e0e08|1|2|3|4|5|6|7|8|9|_|1|2|3|4|>|║+0&#ffd7ff255| 
+|~+0#4040ff13#ffffff0| @35||+1#0000000&|~+0#4040ff13&| @15| 
+0#0000001#ffd7ff255|║| |1|2|3|4|5|6|7|8|9|_|1|2|3|4|>|║| 
+|~+0#4040ff13#ffffff0| @35||+1#0000000&|~+0#4040ff13&| @15| 
+0#0000001#ffd7ff255|╚|═@15|╝| 
diff --git a/src/testdir/dumps/Test_popup_border_end_m_21.dump 
b/src/testdir/dumps/Test_popup_border_end_m_21.dump
new file mode 100644
index 000000000..0ec7ce2d9
--- /dev/null
+++ b/src/testdir/dumps/Test_popup_border_end_m_21.dump
@@ -0,0 +1,8 @@
+|1+0&#ffffff0|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a| 
@5||+1&&|1+0&&|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a| @5
+|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b| 
@5||+1&&|1+0&&|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b| @5
+@21|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6||+1&&| 
+0&&@20|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6
+|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a| @21||+1&&|7+0&&|8|9|_|1|2|3|4|5|6|7|8|9|_|a> 
@21
+|~+0#4040ff13&| @35||+1#0000000&|~+0#4040ff13&| @15| 
+0#0000001#ffd7ff255|╔|═@15|╗| 
+|~+0#4040ff13#ffffff0| @35||+1#0000000&|~+0#4040ff13&| @15| 
+0#0000001#ffd7ff255|║| 
+0&#e0e0e08|1|2|3|4|5|6|7|8|9|_|1|2|3|4|>|║+0&#ffd7ff255| 
+|~+0#4040ff13#ffffff0| @35||+1#0000000&|~+0#4040ff13&| @15| 
+0#0000001#ffd7ff255|║| |1|2|3|4|5|6|7|8|9|_|1|2|3|4|>|║| 
+|~+0#4040ff13#ffffff0| @35||+1#0000000&|~+0#4040ff13&| @15| 
+0#0000001#ffd7ff255|╚|═@15|╝| 
diff --git a/src/testdir/dumps/Test_popup_border_end_m_4.dump 
b/src/testdir/dumps/Test_popup_border_end_m_4.dump
new file mode 100644
index 000000000..395fe80a4
--- /dev/null
+++ b/src/testdir/dumps/Test_popup_border_end_m_4.dump
@@ -0,0 +1,8 @@
+|1+0&#ffffff0|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a| 
@5||+1&&|1+0&&|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a| @5
+|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b| 
@5||+1&&|1+0&&|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b| @5
+@4|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a| @1||+1&&| 
+0&&@3|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a> @1
+|~+0#4040ff13&| @35||+1#0000000&|~+0#4040ff13&| +0#0000001#ffd7ff255|╔|═@31|╗| 
+|~+0#4040ff13#ffffff0| @35||+1#0000000&|~+0#4040ff13&| +0#0000001#ffd7ff255|║| 
+0&#e0e0e08|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a|║+0&#ffd7ff255|
 
+|~+0#4040ff13#ffffff0| @35||+1#0000000&|~+0#4040ff13&| +0#0000001#ffd7ff255|║| 
|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b|║| 
+|~+0#4040ff13#ffffff0| @35||+1#0000000&|~+0#4040ff13&| 
+0#0000001#ffd7ff255|╚|═@31|╝| 
+|~+0#4040ff13#ffffff0| @35||+1#0000000&|~+0#4040ff13&| @35
diff --git a/src/testdir/dumps/Test_popup_border_end_m_5.dump 
b/src/testdir/dumps/Test_popup_border_end_m_5.dump
new file mode 100644
index 000000000..63b960f54
--- /dev/null
+++ b/src/testdir/dumps/Test_popup_border_end_m_5.dump
@@ -0,0 +1,8 @@
+|1+0&#ffffff0|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a| 
@5||+1&&|1+0&&|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a| @5
+|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b| 
@5||+1&&|1+0&&|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b| @5
+@5|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a| ||+1&&| 
+0&&@4|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a> 
+|~+0#4040ff13&| @35||+1#0000000&|~+0#4040ff13&| | 
+0#0000001#ffd7ff255|╔|═@30|╗| 
+|~+0#4040ff13#ffffff0| @35||+1#0000000&|~+0#4040ff13&| | 
+0#0000001#ffd7ff255|║| 
+0&#e0e0e08|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|>|║+0&#ffd7ff255|
 
+|~+0#4040ff13#ffffff0| @35||+1#0000000&|~+0#4040ff13&| | 
+0#0000001#ffd7ff255|║| 
|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|>|║| 
+|~+0#4040ff13#ffffff0| @35||+1#0000000&|~+0#4040ff13&| | 
+0#0000001#ffd7ff255|╚|═@30|╝| 
+|~+0#4040ff13#ffffff0| @35||+1#0000000&|~+0#4040ff13&| @35
diff --git a/src/testdir/dumps/Test_popup_border_end_m_s_17.dump 
b/src/testdir/dumps/Test_popup_border_end_m_s_17.dump
new file mode 100644
index 000000000..1aadce03b
--- /dev/null
+++ b/src/testdir/dumps/Test_popup_border_end_m_s_17.dump
@@ -0,0 +1,8 @@
+|1+0&#ffffff0|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a| 
@5||+1&&|1+0&&|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a| @5
+|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b| 
@5||+1&&|1+0&&|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b| @5
+@17|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_||+1&&| 
+0&&@16|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_
+|1|2|3|4|5|6|7|8|9|_|a| @25||+1&&|1+0&&|2|3|4|5|6|7|8|9|_|a> @25
+|~+0#4040ff13&| @35||+1#0000000&|~+0#4040ff13&| @12| 
+0#0000001#ffd7ff255|╔|═@16|╗| | +0#4040ff13#ffffff0@1
+|~| @35||+1#0000000&|~+0#4040ff13&| @12| +0#0000001#ffd7ff255|║| 
+0&#e0e0e08|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|>|║+0&#ffd7ff255| | 
+0#6c6c6c255#0000001@1
+|~+0#4040ff13#ffffff0| @35||+1#0000000&|~+0#4040ff13&| @12| 
+0#0000001#ffd7ff255|║| |1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|>|║| | 
+0#6c6c6c255#0000001@1
+|~+0#4040ff13#ffffff0| @35||+1#0000000&|~+0#4040ff13&| @12| 
+0#0000001#ffd7ff255|╚|═@16|╝| | +0#6c6c6c255#0000001@1
diff --git a/src/testdir/dumps/Test_popup_border_end_m_s_18.dump 
b/src/testdir/dumps/Test_popup_border_end_m_s_18.dump
new file mode 100644
index 000000000..2dcdaa77e
--- /dev/null
+++ b/src/testdir/dumps/Test_popup_border_end_m_s_18.dump
@@ -0,0 +1,8 @@
+|1+0&#ffffff0|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a| 
@5||+1&&|1+0&&|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a| @5
+|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b| 
@5||+1&&|1+0&&|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b| @5
+@18|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9||+1&&| 
+0&&@17|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9
+|_|1|2|3|4|5|6|7|8|9|_|a| @24||+1&&|_+0&&|1|2|3|4|5|6|7|8|9|_|a> @24
+|~+0#4040ff13&| @35||+1#0000000&|~+0#4040ff13&| @13| 
+0#0000001#ffd7ff255|╔|═@15|╗| | +0#4040ff13#ffffff0@1
+|~| @35||+1#0000000&|~+0#4040ff13&| @13| +0#0000001#ffd7ff255|║| 
+0&#e0e0e08|1|2|3|4|5|6|7|8|9|_|1|2|3|4|>|║+0&#ffd7ff255| | 
+0#6c6c6c255#0000001@1
+|~+0#4040ff13#ffffff0| @35||+1#0000000&|~+0#4040ff13&| @13| 
+0#0000001#ffd7ff255|║| |1|2|3|4|5|6|7|8|9|_|1|2|3|4|>|║| | 
+0#6c6c6c255#0000001@1
+|~+0#4040ff13#ffffff0| @35||+1#0000000&|~+0#4040ff13&| @13| 
+0#0000001#ffd7ff255|╚|═@15|╝| | +0#6c6c6c255#0000001@1
diff --git a/src/testdir/dumps/Test_popup_border_end_m_s_19.dump 
b/src/testdir/dumps/Test_popup_border_end_m_s_19.dump
new file mode 100644
index 000000000..c36849fcf
--- /dev/null
+++ b/src/testdir/dumps/Test_popup_border_end_m_s_19.dump
@@ -0,0 +1,8 @@
+|1+0&#ffffff0|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a| 
@5||+1&&|1+0&&|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a| @5
+|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b| 
@5||+1&&|1+0&&|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b| @5
+@19|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8||+1&&| 
+0&&@18|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8
+|9|_|1|2|3|4|5|6|7|8|9|_|a| @23||+1&&|9+0&&|_|1|2|3|4|5|6|7|8|9|_|a> @23
+|~+0#4040ff13&| @35||+1#0000000&|~+0#4040ff13&| @13| 
+0#0000001#ffd7ff255|╔|═@15|╗| | +0#4040ff13#ffffff0@1
+|~| @35||+1#0000000&|~+0#4040ff13&| @13| +0#0000001#ffd7ff255|║| 
+0&#e0e0e08|1|2|3|4|5|6|7|8|9|_|1|2|3|4|>|║+0&#ffd7ff255| | 
+0#6c6c6c255#0000001@1
+|~+0#4040ff13#ffffff0| @35||+1#0000000&|~+0#4040ff13&| @13| 
+0#0000001#ffd7ff255|║| |1|2|3|4|5|6|7|8|9|_|1|2|3|4|>|║| | 
+0#6c6c6c255#0000001@1
+|~+0#4040ff13#ffffff0| @35||+1#0000000&|~+0#4040ff13&| @13| 
+0#0000001#ffd7ff255|╚|═@15|╝| | +0#6c6c6c255#0000001@1
diff --git a/src/testdir/dumps/Test_popup_border_end_m_s_2.dump 
b/src/testdir/dumps/Test_popup_border_end_m_s_2.dump
new file mode 100644
index 000000000..4f27bc51b
--- /dev/null
+++ b/src/testdir/dumps/Test_popup_border_end_m_s_2.dump
@@ -0,0 +1,8 @@
+|1+0&#ffffff0|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a| 
@5||+1&&|1+0&&|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a| @5
+|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b| 
@5||+1&&|1+0&&|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b| @5
+@2|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a| @3||+1&&| 
+0&&@1|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a> @3
+|~+0#4040ff13&| @35| +0#0000001#ffd7ff255|╔|═@31|╗| | +0#4040ff13#ffffff0@1
+|~| @35| +0#0000001#ffd7ff255|║| 
+0&#e0e0e08|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a|║+0&#ffd7ff255|
 | +0#6c6c6c255#0000001@1
+|~+0#4040ff13#ffffff0| @35| +0#0000001#ffd7ff255|║| 
|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b|║| | 
+0#6c6c6c255#0000001@1
+|~+0#4040ff13#ffffff0| @35| +0#0000001#ffd7ff255|╚|═@31|╝| | 
+0#6c6c6c255#0000001@1
+|~+0#4040ff13#ffffff0| @35||+1#0000000&|~+0#4040ff13&| +0#6c6c6c255#0000001@35
diff --git a/src/testdir/dumps/Test_popup_border_end_m_s_3.dump 
b/src/testdir/dumps/Test_popup_border_end_m_s_3.dump
new file mode 100644
index 000000000..aea5a163f
--- /dev/null
+++ b/src/testdir/dumps/Test_popup_border_end_m_s_3.dump
@@ -0,0 +1,8 @@
+|1+0&#ffffff0|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a| 
@5||+1&&|1+0&&|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a| @5
+|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b| 
@5||+1&&|1+0&&|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b| @5
+@3|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a| @2||+1&&| 
+0&&@2|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a> @2
+|~+0#4040ff13&| @35||+1#0000000&| +0#0000001#ffd7ff255|╔|═@30|╗| | 
+0#4040ff13#ffffff0@1
+|~| @35||+1#0000000&| +0#0000001#ffd7ff255|║| 
+0&#e0e0e08|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|>|║+0&#ffd7ff255|
 | +0#6c6c6c255#0000001@1
+|~+0#4040ff13#ffffff0| @35||+1#0000000&| +0#0000001#ffd7ff255|║| 
|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|>|║| | 
+0#6c6c6c255#0000001@1
+|~+0#4040ff13#ffffff0| @35||+1#0000000&| +0#0000001#ffd7ff255|╚|═@30|╝| | 
+0#6c6c6c255#0000001@1
+|~+0#4040ff13#ffffff0| @35||+1#0000000&|~+0#4040ff13&| | 
+0#6c6c6c255#0000001@34
diff --git a/src/testdir/dumps/Test_popup_border_end_rtl_20.dump 
b/src/testdir/dumps/Test_popup_border_end_rtl_20.dump
new file mode 100644
index 000000000..fcd14f1d5
--- /dev/null
+++ b/src/testdir/dumps/Test_popup_border_end_rtl_20.dump
@@ -0,0 +1,8 @@
+| 
+0&#ffffff0@5|a|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1||+1&&|1+0&&|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a|
 @5
+@6|b|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1||+1&&|1+0&&|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b|
 @5
+|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1| @19||+1&&| 
+0&&@19|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7
+| @21> |a|_|9|8|7|6|5|4|3|2|1|_|9|8||+1&&|8+0&&|9|_|1|2|3|4|5|6|7|8|9|_|a| @22
+|╔+0#0000001#ffd7ff255|═@16|╗| 
+0#4040ff13#ffffff0@16|~||+1#0000000&|~+0#4040ff13&| @35
+|║+0#0000001#ffd7ff255|<+0&#e0e0e08|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1| 
|║+0&#ffd7ff255| +0#4040ff13#ffffff0@16|~||+1#0000000&|~+0#4040ff13&| @35
+|║+0#0000001#ffd7ff255|<|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1| |║| 
+0#4040ff13#ffffff0@16|~||+1#0000000&|~+0#4040ff13&| @35
+|╚+0#0000001#ffd7ff255|═@16|╝| 
+0#4040ff13#ffffff0@16|~||+1#0000000&|~+0#4040ff13&| @35
diff --git a/src/testdir/dumps/Test_popup_border_end_rtl_21.dump 
b/src/testdir/dumps/Test_popup_border_end_rtl_21.dump
new file mode 100644
index 000000000..2d4f3b02b
--- /dev/null
+++ b/src/testdir/dumps/Test_popup_border_end_rtl_21.dump
@@ -0,0 +1,8 @@
+| 
+0&#ffffff0@5|a|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1||+1&&|1+0&&|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a|
 @5
+@6|b|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1||+1&&|1+0&&|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b|
 @5
+|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1| @20||+1&&| 
+0&&@20|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6
+| @20> |a|_|9|8|7|6|5|4|3|2|1|_|9|8|7||+1&&|7+0&&|8|9|_|1|2|3|4|5|6|7|8|9|_|a| 
@21
+| +0#4040ff13&|╔+0#0000001#ffd7ff255|═@15|╗| 
+0#4040ff13#ffffff0@16|~||+1#0000000&|~+0#4040ff13&| @35
+@1|║+0#0000001#ffd7ff255|<+0&#e0e0e08|4|3|2|1|_|9|8|7|6|5|4|3|2|1| 
|║+0&#ffd7ff255| +0#4040ff13#ffffff0@16|~||+1#0000000&|~+0#4040ff13&| @35
+@1|║+0#0000001#ffd7ff255|<|4|3|2|1|_|9|8|7|6|5|4|3|2|1| |║| 
+0#4040ff13#ffffff0@16|~||+1#0000000&|~+0#4040ff13&| @35
+@1|╚+0#0000001#ffd7ff255|═@15|╝| 
+0#4040ff13#ffffff0@16|~||+1#0000000&|~+0#4040ff13&| @35
diff --git a/src/testdir/dumps/Test_popup_border_end_rtl_22.dump 
b/src/testdir/dumps/Test_popup_border_end_rtl_22.dump
new file mode 100644
index 000000000..479856071
--- /dev/null
+++ b/src/testdir/dumps/Test_popup_border_end_rtl_22.dump
@@ -0,0 +1,8 @@
+| 
+0&#ffffff0@5|a|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1||+1&&|1+0&&|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a|
 @5
+@6|b|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1||+1&&|1+0&&|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b|
 @5
+|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1| @21||+1&&| 
+0&&@21|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5
+| @19> 
|a|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6||+1&&|6+0&&|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a| @20
+| +0#4040ff13&|╔+0#0000001#ffd7ff255|═@15|╗| 
+0#4040ff13#ffffff0@16|~||+1#0000000&|~+0#4040ff13&| @35
+@1|║+0#0000001#ffd7ff255|<+0&#e0e0e08|4|3|2|1|_|9|8|7|6|5|4|3|2|1| 
|║+0&#ffd7ff255| +0#4040ff13#ffffff0@16|~||+1#0000000&|~+0#4040ff13&| @35
+@1|║+0#0000001#ffd7ff255|<|4|3|2|1|_|9|8|7|6|5|4|3|2|1| |║| 
+0#4040ff13#ffffff0@16|~||+1#0000000&|~+0#4040ff13&| @35
+@1|╚+0#0000001#ffd7ff255|═@15|╝| 
+0#4040ff13#ffffff0@16|~||+1#0000000&|~+0#4040ff13&| @35
diff --git a/src/testdir/dumps/Test_popup_border_end_rtl_5.dump 
b/src/testdir/dumps/Test_popup_border_end_rtl_5.dump
new file mode 100644
index 000000000..2bd9613bc
--- /dev/null
+++ b/src/testdir/dumps/Test_popup_border_end_rtl_5.dump
@@ -0,0 +1,8 @@
+| 
+0&#ffffff0@5|a|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1||+1&&|1+0&&|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a|
 @5
+@6|b|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1||+1&&|1+0&&|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b|
 @5
+> |a|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1| @4||+1&&| 
+0&&@4|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a| 
+|╔+0#0000001#ffd7ff255|═@31|╗| 
+0#4040ff13#ffffff0@1|~||+1#0000000&|~+0#4040ff13&| @35
+|║+0#0000001#ffd7ff255|a+0&#e0e0e08|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|
 |║+0&#ffd7ff255| +0#4040ff13#ffffff0@1|~||+1#0000000&|~+0#4040ff13&| @35
+|║+0#0000001#ffd7ff255|b|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|
 |║| +0#4040ff13#ffffff0@1|~||+1#0000000&|~+0#4040ff13&| @35
+|╚+0#0000001#ffd7ff255|═@31|╝| 
+0#4040ff13#ffffff0@1|~||+1#0000000&|~+0#4040ff13&| @35
+@36|~||+1#0000000&|~+0#4040ff13&| @35
diff --git a/src/testdir/dumps/Test_popup_border_end_rtl_6.dump 
b/src/testdir/dumps/Test_popup_border_end_rtl_6.dump
new file mode 100644
index 000000000..155253326
--- /dev/null
+++ b/src/testdir/dumps/Test_popup_border_end_rtl_6.dump
@@ -0,0 +1,8 @@
+| 
+0&#ffffff0@5|a|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1||+1&&|1+0&&|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a|
 @5
+@6|b|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1||+1&&|1+0&&|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b|
 @5
+|a|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1| @5||+1&&| 
+0&&@5|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a
+|╔+0#0000001#ffd7ff255|═@30|╗| 
+0#4040ff13#ffffff0@2>~||+1#0000000&|~+0#4040ff13&| @35
+|║+0#0000001#ffd7ff255|<+0&#e0e0e08|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|
 |║+0&#ffd7ff255| +0#4040ff13#ffffff0@2|~||+1#0000000&|~+0#4040ff13&| @35
+|║+0#0000001#ffd7ff255|<|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|
 |║| +0#4040ff13#ffffff0@2|~||+1#0000000&|~+0#4040ff13&| @35
+|╚+0#0000001#ffd7ff255|═@30|╝| 
+0#4040ff13#ffffff0@2|~||+1#0000000&|~+0#4040ff13&| @35
+@36|~||+1#0000000&|~+0#4040ff13&| @35
diff --git a/src/testdir/dumps/Test_popup_border_end_rtl_m_19.dump 
b/src/testdir/dumps/Test_popup_border_end_rtl_m_19.dump
new file mode 100644
index 000000000..5c6ef7a52
--- /dev/null
+++ b/src/testdir/dumps/Test_popup_border_end_rtl_m_19.dump
@@ -0,0 +1,8 @@
+| 
+0&#ffffff0@5|a|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1||+1&&|1+0&&|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a|
 @5
+@6|b|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1||+1&&|1+0&&|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b|
 @5
+|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1| @18||+1&&| 
+0&&@18|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8
+| @22> |a|_|9|8|7|6|5|4|3|2|1|_|9||+1&&|9+0&&|_|1|2|3|4|5|6|7|8|9|_|a| @23
+| +0#0000001#ffd7ff255|╔|═@16|╗| | 
+0#4040ff13#ffffff0@14|~||+1#0000000&|~+0#4040ff13&| @35
+| +0#0000001#ffd7ff255|║|<+0&#e0e0e08|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1| 
|║+0&#ffd7ff255| | +0#4040ff13#ffffff0@14|~||+1#0000000&|~+0#4040ff13&| @35
+| +0#0000001#ffd7ff255|║|<|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1| |║| | 
+0#4040ff13#ffffff0@14|~||+1#0000000&|~+0#4040ff13&| @35
+| +0#0000001#ffd7ff255|╚|═@16|╝| | 
+0#4040ff13#ffffff0@14|~||+1#0000000&|~+0#4040ff13&| @35
diff --git a/src/testdir/dumps/Test_popup_border_end_rtl_m_20.dump 
b/src/testdir/dumps/Test_popup_border_end_rtl_m_20.dump
new file mode 100644
index 000000000..df1000dac
--- /dev/null
+++ b/src/testdir/dumps/Test_popup_border_end_rtl_m_20.dump
@@ -0,0 +1,8 @@
+| 
+0&#ffffff0@5|a|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1||+1&&|1+0&&|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a|
 @5
+@6|b|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1||+1&&|1+0&&|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b|
 @5
+|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1| @19||+1&&| 
+0&&@19|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7
+| @21> |a|_|9|8|7|6|5|4|3|2|1|_|9|8||+1&&|8+0&&|9|_|1|2|3|4|5|6|7|8|9|_|a| @22
+| +0#4040ff13&| +0#0000001#ffd7ff255|╔|═@15|╗| | 
+0#4040ff13#ffffff0@14|~||+1#0000000&|~+0#4040ff13&| @35
+@1| +0#0000001#ffd7ff255|║|<+0&#e0e0e08|4|3|2|1|_|9|8|7|6|5|4|3|2|1| 
|║+0&#ffd7ff255| | +0#4040ff13#ffffff0@14|~||+1#0000000&|~+0#4040ff13&| @35
+@1| +0#0000001#ffd7ff255|║|<|4|3|2|1|_|9|8|7|6|5|4|3|2|1| |║| | 
+0#4040ff13#ffffff0@14|~||+1#0000000&|~+0#4040ff13&| @35
+@1| +0#0000001#ffd7ff255|╚|═@15|╝| | 
+0#4040ff13#ffffff0@14|~||+1#0000000&|~+0#4040ff13&| @35
diff --git a/src/testdir/dumps/Test_popup_border_end_rtl_m_21.dump 
b/src/testdir/dumps/Test_popup_border_end_rtl_m_21.dump
new file mode 100644
index 000000000..bccd2406f
--- /dev/null
+++ b/src/testdir/dumps/Test_popup_border_end_rtl_m_21.dump
@@ -0,0 +1,8 @@
+| 
+0&#ffffff0@5|a|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1||+1&&|1+0&&|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a|
 @5
+@6|b|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1||+1&&|1+0&&|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b|
 @5
+|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1| @20||+1&&| 
+0&&@20|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6
+| @20> |a|_|9|8|7|6|5|4|3|2|1|_|9|8|7||+1&&|7+0&&|8|9|_|1|2|3|4|5|6|7|8|9|_|a| 
@21
+| +0#4040ff13&| +0#0000001#ffd7ff255|╔|═@15|╗| | 
+0#4040ff13#ffffff0@14|~||+1#0000000&|~+0#4040ff13&| @35
+@1| +0#0000001#ffd7ff255|║|<+0&#e0e0e08|4|3|2|1|_|9|8|7|6|5|4|3|2|1| 
|║+0&#ffd7ff255| | +0#4040ff13#ffffff0@14|~||+1#0000000&|~+0#4040ff13&| @35
+@1| +0#0000001#ffd7ff255|║|<|4|3|2|1|_|9|8|7|6|5|4|3|2|1| |║| | 
+0#4040ff13#ffffff0@14|~||+1#0000000&|~+0#4040ff13&| @35
+@1| +0#0000001#ffd7ff255|╚|═@15|╝| | 
+0#4040ff13#ffffff0@14|~||+1#0000000&|~+0#4040ff13&| @35
diff --git a/src/testdir/dumps/Test_popup_border_end_rtl_m_4.dump 
b/src/testdir/dumps/Test_popup_border_end_rtl_m_4.dump
new file mode 100644
index 000000000..abca507d0
--- /dev/null
+++ b/src/testdir/dumps/Test_popup_border_end_rtl_m_4.dump
@@ -0,0 +1,8 @@
+| 
+0&#ffffff0@5|a|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1||+1&&|1+0&&|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a|
 @5
+@6|b|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1||+1&&|1+0&&|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b|
 @5
+@1> |a|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1| @3||+1&&| 
+0&&@3|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a| @1
+| +0#0000001#ffd7ff255|╔|═@31|╗| 
|~+0#4040ff13#ffffff0||+1#0000000&|~+0#4040ff13&| @35
+| 
+0#0000001#ffd7ff255|║|a+0&#e0e0e08|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|
 |║+0&#ffd7ff255| |~+0#4040ff13#ffffff0||+1#0000000&|~+0#4040ff13&| @35
+| 
+0#0000001#ffd7ff255|║|b|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|
 |║| |~+0#4040ff13#ffffff0||+1#0000000&|~+0#4040ff13&| @35
+| +0#0000001#ffd7ff255|╚|═@31|╝| 
|~+0#4040ff13#ffffff0||+1#0000000&|~+0#4040ff13&| @35
+@36|~||+1#0000000&|~+0#4040ff13&| @35
diff --git a/src/testdir/dumps/Test_popup_border_end_rtl_m_5.dump 
b/src/testdir/dumps/Test_popup_border_end_rtl_m_5.dump
new file mode 100644
index 000000000..5f43583d9
--- /dev/null
+++ b/src/testdir/dumps/Test_popup_border_end_rtl_m_5.dump
@@ -0,0 +1,8 @@
+| 
+0&#ffffff0@5|a|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1||+1&&|1+0&&|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a|
 @5
+@6|b|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1||+1&&|1+0&&|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b|
 @5
+> |a|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1| @4||+1&&| 
+0&&@4|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a| 
+| +0#0000001#ffd7ff255|╔|═@30|╗| | 
+0#4040ff13#ffffff0|~||+1#0000000&|~+0#4040ff13&| @35
+| 
+0#0000001#ffd7ff255|║|<+0&#e0e0e08|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|
 |║+0&#ffd7ff255| | +0#4040ff13#ffffff0|~||+1#0000000&|~+0#4040ff13&| @35
+| 
+0#0000001#ffd7ff255|║|<|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|
 |║| | +0#4040ff13#ffffff0|~||+1#0000000&|~+0#4040ff13&| @35
+| +0#0000001#ffd7ff255|╚|═@30|╝| | 
+0#4040ff13#ffffff0|~||+1#0000000&|~+0#4040ff13&| @35
+@36|~||+1#0000000&|~+0#4040ff13&| @35
diff --git a/src/testdir/dumps/Test_popup_border_end_rtl_m_s_17.dump 
b/src/testdir/dumps/Test_popup_border_end_rtl_m_s_17.dump
new file mode 100644
index 000000000..f06eabce1
--- /dev/null
+++ b/src/testdir/dumps/Test_popup_border_end_rtl_m_s_17.dump
@@ -0,0 +1,8 @@
+| 
+0&#ffffff0@5|a|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1||+1&&|1+0&&|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a|
 @5
+@6|b|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1||+1&&|1+0&&|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b|
 @5
+|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1| @16||+1&&| 
+0&&@16|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_
+| @24> |a|_|9|8|7|6|5|4|3|2|1||+1&&|1+0&&|2|3|4|5|6|7|8|9|_|a| @25
+| +0#4040ff13&@1| +0#0000001#ffd7ff255|╔|═@16|╗| | 
+0#4040ff13#ffffff0@12|~||+1#0000000&|~+0#4040ff13&| @35
+| +0#6c6c6c255#0000001@1| 
+0#0000001#ffd7ff255|║|<+0&#e0e0e08|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1| 
|║+0&#ffd7ff255| | +0#4040ff13#ffffff0@12|~||+1#0000000&|~+0#4040ff13&| @35
+| +0#6c6c6c255#0000001@1| 
+0#0000001#ffd7ff255|║|<|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1| |║| | 
+0#4040ff13#ffffff0@12|~||+1#0000000&|~+0#4040ff13&| @35
+| +0#6c6c6c255#0000001@1| +0#0000001#ffd7ff255|╚|═@16|╝| | 
+0#4040ff13#ffffff0@12|~||+1#0000000&|~+0#4040ff13&| @35
diff --git a/src/testdir/dumps/Test_popup_border_end_rtl_m_s_18.dump 
b/src/testdir/dumps/Test_popup_border_end_rtl_m_s_18.dump
new file mode 100644
index 000000000..841902c36
--- /dev/null
+++ b/src/testdir/dumps/Test_popup_border_end_rtl_m_s_18.dump
@@ -0,0 +1,8 @@
+| 
+0&#ffffff0@5|a|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1||+1&&|1+0&&|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a|
 @5
+@6|b|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1||+1&&|1+0&&|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b|
 @5
+|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1| @17||+1&&| 
+0&&@17|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9
+| @23> |a|_|9|8|7|6|5|4|3|2|1|_||+1&&|_+0&&|1|2|3|4|5|6|7|8|9|_|a| @24
+| +0#4040ff13&@2| +0#0000001#ffd7ff255|╔|═@15|╗| | 
+0#4040ff13#ffffff0@12|~||+1#0000000&|~+0#4040ff13&| @35
+@1| +0#6c6c6c255#0000001@1| 
+0#0000001#ffd7ff255|║|<+0&#e0e0e08|4|3|2|1|_|9|8|7|6|5|4|3|2|1| 
|║+0&#ffd7ff255| | +0#4040ff13#ffffff0@12|~||+1#0000000&|~+0#4040ff13&| @35
+@1| +0#6c6c6c255#0000001@1| 
+0#0000001#ffd7ff255|║|<|4|3|2|1|_|9|8|7|6|5|4|3|2|1| |║| | 
+0#4040ff13#ffffff0@12|~||+1#0000000&|~+0#4040ff13&| @35
+@1| +0#6c6c6c255#0000001@1| +0#0000001#ffd7ff255|╚|═@15|╝| | 
+0#4040ff13#ffffff0@12|~||+1#0000000&|~+0#4040ff13&| @35
diff --git a/src/testdir/dumps/Test_popup_border_end_rtl_m_s_19.dump 
b/src/testdir/dumps/Test_popup_border_end_rtl_m_s_19.dump
new file mode 100644
index 000000000..46ab60068
--- /dev/null
+++ b/src/testdir/dumps/Test_popup_border_end_rtl_m_s_19.dump
@@ -0,0 +1,8 @@
+| 
+0&#ffffff0@5|a|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1||+1&&|1+0&&|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a|
 @5
+@6|b|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1||+1&&|1+0&&|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b|
 @5
+|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1| @18||+1&&| 
+0&&@18|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8
+| @22> |a|_|9|8|7|6|5|4|3|2|1|_|9||+1&&|9+0&&|_|1|2|3|4|5|6|7|8|9|_|a| @23
+| +0#4040ff13&@2| +0#0000001#ffd7ff255|╔|═@15|╗| | 
+0#4040ff13#ffffff0@12|~||+1#0000000&|~+0#4040ff13&| @35
+@1| +0#6c6c6c255#0000001@1| 
+0#0000001#ffd7ff255|║|<+0&#e0e0e08|4|3|2|1|_|9|8|7|6|5|4|3|2|1| 
|║+0&#ffd7ff255| | +0#4040ff13#ffffff0@12|~||+1#0000000&|~+0#4040ff13&| @35
+@1| +0#6c6c6c255#0000001@1| 
+0#0000001#ffd7ff255|║|<|4|3|2|1|_|9|8|7|6|5|4|3|2|1| |║| | 
+0#4040ff13#ffffff0@12|~||+1#0000000&|~+0#4040ff13&| @35
+@1| +0#6c6c6c255#0000001@1| +0#0000001#ffd7ff255|╚|═@15|╝| | 
+0#4040ff13#ffffff0@12|~||+1#0000000&|~+0#4040ff13&| @35
diff --git a/src/testdir/dumps/Test_popup_border_end_rtl_m_s_2.dump 
b/src/testdir/dumps/Test_popup_border_end_rtl_m_s_2.dump
new file mode 100644
index 000000000..e1b85febd
--- /dev/null
+++ b/src/testdir/dumps/Test_popup_border_end_rtl_m_s_2.dump
@@ -0,0 +1,8 @@
+| 
+0&#ffffff0@5|a|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1||+1&&|1+0&&|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a|
 @5
+@6|b|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1||+1&&|1+0&&|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b|
 @5
+@3> |a|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1| @1||+1&&| 
+0&&@1|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a| @3
+| +0#4040ff13&@1| +0#0000001#ffd7ff255|╔|═@31|╗| |~+0#4040ff13#ffffff0| @35
+| +0#6c6c6c255#0000001@1| 
+0#0000001#ffd7ff255|║|a+0&#e0e0e08|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|
 |║+0&#ffd7ff255| |~+0#4040ff13#ffffff0| @35
+| +0#6c6c6c255#0000001@1| 
+0#0000001#ffd7ff255|║|b|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|
 |║| |~+0#4040ff13#ffffff0| @35
+| +0#6c6c6c255#0000001@1| +0#0000001#ffd7ff255|╚|═@31|╝| 
|~+0#4040ff13#ffffff0| @35
+| +0#6c6c6c255#0000001@35|~+0#4040ff13#ffffff0||+1#0000000&|~+0#4040ff13&| @35
diff --git a/src/testdir/dumps/Test_popup_border_end_rtl_m_s_3.dump 
b/src/testdir/dumps/Test_popup_border_end_rtl_m_s_3.dump
new file mode 100644
index 000000000..4e91f0d1b
--- /dev/null
+++ b/src/testdir/dumps/Test_popup_border_end_rtl_m_s_3.dump
@@ -0,0 +1,8 @@
+| 
+0&#ffffff0@5|a|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1||+1&&|1+0&&|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a|
 @5
+@6|b|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1||+1&&|1+0&&|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b|
 @5
+@2> |a|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1| @2||+1&&| 
+0&&@2|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a| @2
+| +0#4040ff13&@1| +0#0000001#ffd7ff255|╔|═@30|╗| 
||+1#0000000#ffffff0|~+0#4040ff13&| @35
+| +0#6c6c6c255#0000001@1| 
+0#0000001#ffd7ff255|║|<+0&#e0e0e08|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|
 |║+0&#ffd7ff255| ||+1#0000000#ffffff0|~+0#4040ff13&| @35
+| +0#6c6c6c255#0000001@1| 
+0#0000001#ffd7ff255|║|<|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|
 |║| ||+1#0000000#ffffff0|~+0#4040ff13&| @35
+| +0#6c6c6c255#0000001@1| +0#0000001#ffd7ff255|╚|═@30|╝| 
||+1#0000000#ffffff0|~+0#4040ff13&| @35
+| +0#6c6c6c255#0000001@34| +0#4040ff13#ffffff0|~||+1#0000000&|~+0#4040ff13&| 
@35
diff --git a/src/testdir/dumps/Test_popup_border_start_0.dump 
b/src/testdir/dumps/Test_popup_border_start_0.dump
new file mode 100644
index 000000000..aa89435f6
--- /dev/null
+++ b/src/testdir/dumps/Test_popup_border_start_0.dump
@@ -0,0 +1,8 @@
+|1+0&#ffffff0|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a| @43
+|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b| @43
+|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a> @43
+|╔+0#0000001#ffd7ff255|═@32|╗| +0#4040ff13#ffffff0@39
+|║+0#0000001#ffd7ff255| 
+0&#e0e0e08|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a| 
|║+0&#ffd7ff255| +0#4040ff13#ffffff0@39
+|║+0#0000001#ffd7ff255| 
|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b| |║| 
+0#4040ff13#ffffff0@39
+|╚+0#0000001#ffd7ff255|═@32|╝| +0#4040ff13#ffffff0@39
+|~| @73
diff --git a/src/testdir/dumps/Test_popup_border_start_0_m.dump 
b/src/testdir/dumps/Test_popup_border_start_0_m.dump
new file mode 100644
index 000000000..97a38dccf
--- /dev/null
+++ b/src/testdir/dumps/Test_popup_border_start_0_m.dump
@@ -0,0 +1,8 @@
+|1+0&#ffffff0|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a| @43
+|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b| @43
+|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a> @43
+|╔+0#0000001#ffd7ff255|═@32|╗| | +0#4040ff13#ffffff0@38
+|║+0#0000001#ffd7ff255| 
+0&#e0e0e08|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a| 
|║+0&#ffd7ff255| | +0#4040ff13#ffffff0@38
+|║+0#0000001#ffd7ff255| 
|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b| |║| | 
+0#4040ff13#ffffff0@38
+|╚+0#0000001#ffd7ff255|═@32|╝| | +0#4040ff13#ffffff0@38
+|~| @73
diff --git a/src/testdir/dumps/Test_popup_border_start_1.dump 
b/src/testdir/dumps/Test_popup_border_start_1.dump
new file mode 100644
index 000000000..48a2077ba
--- /dev/null
+++ b/src/testdir/dumps/Test_popup_border_start_1.dump
@@ -0,0 +1,8 @@
+|1+0&#ffffff0|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a| @43
+|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b| @43
+@1|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a> @42
+|╔+0#0000001#ffd7ff255|═@32|╗| +0#4040ff13#ffffff0@39
+|║+0#0000001#ffd7ff255| 
+0&#e0e0e08|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a| 
|║+0&#ffd7ff255| +0#4040ff13#ffffff0@39
+|║+0#0000001#ffd7ff255| 
|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b| |║| 
+0#4040ff13#ffffff0@39
+|╚+0#0000001#ffd7ff255|═@32|╝| +0#4040ff13#ffffff0@39
+|~| @73
diff --git a/src/testdir/dumps/Test_popup_border_start_1_m.dump 
b/src/testdir/dumps/Test_popup_border_start_1_m.dump
new file mode 100644
index 000000000..f39fb58c1
--- /dev/null
+++ b/src/testdir/dumps/Test_popup_border_start_1_m.dump
@@ -0,0 +1,8 @@
+|1+0&#ffffff0|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a| @43
+|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b| @43
+@1|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a> @42
+|╔+0#0000001#ffd7ff255|═@32|╗| | +0#4040ff13#ffffff0@38
+|║+0#0000001#ffd7ff255| 
+0&#e0e0e08|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a| 
|║+0&#ffd7ff255| | +0#4040ff13#ffffff0@38
+|║+0#0000001#ffd7ff255| 
|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b| |║| | 
+0#4040ff13#ffffff0@38
+|╚+0#0000001#ffd7ff255|═@32|╝| | +0#4040ff13#ffffff0@38
+|~| @73
diff --git a/src/testdir/dumps/Test_popup_border_start_2.dump 
b/src/testdir/dumps/Test_popup_border_start_2.dump
new file mode 100644
index 000000000..d6bfe302c
--- /dev/null
+++ b/src/testdir/dumps/Test_popup_border_start_2.dump
@@ -0,0 +1,8 @@
+|1+0&#ffffff0|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a| @43
+|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b| @43
+@2|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a> @41
+|╔+0#0000001#ffd7ff255|═@32|╗| +0#4040ff13#ffffff0@39
+|║+0#0000001#ffd7ff255| 
+0&#e0e0e08|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a| 
|║+0&#ffd7ff255| +0#4040ff13#ffffff0@39
+|║+0#0000001#ffd7ff255| 
|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b| |║| 
+0#4040ff13#ffffff0@39
+|╚+0#0000001#ffd7ff255|═@32|╝| +0#4040ff13#ffffff0@39
+|~| @73
diff --git a/src/testdir/dumps/Test_popup_border_start_2_m.dump 
b/src/testdir/dumps/Test_popup_border_start_2_m.dump
new file mode 100644
index 000000000..bbb63bd1d
--- /dev/null
+++ b/src/testdir/dumps/Test_popup_border_start_2_m.dump
@@ -0,0 +1,8 @@
+|1+0&#ffffff0|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a| @43
+|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b| @43
+@2|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a> @41
+|╔+0#0000001#ffd7ff255|═@32|╗| | +0#4040ff13#ffffff0@38
+|║+0#0000001#ffd7ff255| 
+0&#e0e0e08|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a| 
|║+0&#ffd7ff255| | +0#4040ff13#ffffff0@38
+|║+0#0000001#ffd7ff255| 
|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b| |║| | 
+0#4040ff13#ffffff0@38
+|╚+0#0000001#ffd7ff255|═@32|╝| | +0#4040ff13#ffffff0@38
+|~| @73
diff --git a/src/testdir/dumps/Test_popup_border_start_5.dump 
b/src/testdir/dumps/Test_popup_border_start_5.dump
new file mode 100644
index 000000000..aeb28174e
--- /dev/null
+++ b/src/testdir/dumps/Test_popup_border_start_5.dump
@@ -0,0 +1,8 @@
+|1+0&#ffffff0|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a| @43
+|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b| @43
+@5|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a> @38
+|~+0#4040ff13&| @1|╔+0#0000001#ffd7ff255|═@32|╗| +0#4040ff13#ffffff0@36
+|~| @1|║+0#0000001#ffd7ff255| 
+0&#e0e0e08|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a| 
|║+0&#ffd7ff255| +0#4040ff13#ffffff0@36
+|~| @1|║+0#0000001#ffd7ff255| 
|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b| |║| 
+0#4040ff13#ffffff0@36
+|~| @1|╚+0#0000001#ffd7ff255|═@32|╝| +0#4040ff13#ffffff0@36
+|~| @73
diff --git a/src/testdir/dumps/Test_popup_border_start_5_m.dump 
b/src/testdir/dumps/Test_popup_border_start_5_m.dump
new file mode 100644
index 000000000..876115b6f
--- /dev/null
+++ b/src/testdir/dumps/Test_popup_border_start_5_m.dump
@@ -0,0 +1,8 @@
+|1+0&#ffffff0|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a| @43
+|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b| @43
+@5|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a> @38
+|~+0#4040ff13&| | +0#0000001#ffd7ff255|╔|═@32|╗| | +0#4040ff13#ffffff0@35
+|~| | +0#0000001#ffd7ff255|║| 
+0&#e0e0e08|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|a| 
|║+0&#ffd7ff255| | +0#4040ff13#ffffff0@35
+|~| | +0#0000001#ffd7ff255|║| 
|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b| |║| | 
+0#4040ff13#ffffff0@35
+|~| | +0#0000001#ffd7ff255|╚|═@32|╝| | +0#4040ff13#ffffff0@35
+|~| @73
diff --git a/src/testdir/dumps/Test_popup_border_start_rtl_0.dump 
b/src/testdir/dumps/Test_popup_border_start_rtl_0.dump
new file mode 100644
index 000000000..2c6bb93eb
--- /dev/null
+++ b/src/testdir/dumps/Test_popup_border_start_rtl_0.dump
@@ -0,0 +1,8 @@
+| +0&#ffffff0@43|a|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1
+| @43|b|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1
+| @42> |a|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1
+| +0#4040ff13&@39|╔+0#0000001#ffd7ff255|═@32|╗
+| +0#4040ff13#ffffff0@39|║+0#0000001#ffd7ff255| 
+0&#e0e0e08|a|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1| 
|║+0&#ffd7ff255
+| +0#4040ff13#ffffff0@39|║+0#0000001#ffd7ff255| 
|b|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1| |║
+| +0#4040ff13#ffffff0@39|╚+0#0000001#ffd7ff255|═@32|╝
+| +0#4040ff13#ffffff0@73|~
diff --git a/src/testdir/dumps/Test_popup_border_start_rtl_0_m.dump 
b/src/testdir/dumps/Test_popup_border_start_rtl_0_m.dump
new file mode 100644
index 000000000..88acf6038
--- /dev/null
+++ b/src/testdir/dumps/Test_popup_border_start_rtl_0_m.dump
@@ -0,0 +1,8 @@
+| +0&#ffffff0@43|a|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1
+| @43|b|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1
+| @42> |a|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1
+| +0#4040ff13&@38| +0#0000001#ffd7ff255|╔|═@32|╗
+| +0#4040ff13#ffffff0@38| +0#0000001#ffd7ff255|║| 
+0&#e0e0e08|a|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1| 
|║+0&#ffd7ff255
+| +0#4040ff13#ffffff0@38| +0#0000001#ffd7ff255|║| 
|b|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1| |║
+| +0#4040ff13#ffffff0@38| +0#0000001#ffd7ff255|╚|═@32|╝
+| +0#4040ff13#ffffff0@73|~
diff --git a/src/testdir/dumps/Test_popup_border_start_rtl_1.dump 
b/src/testdir/dumps/Test_popup_border_start_rtl_1.dump
new file mode 100644
index 000000000..a8ba02496
--- /dev/null
+++ b/src/testdir/dumps/Test_popup_border_start_rtl_1.dump
@@ -0,0 +1,8 @@
+| +0&#ffffff0@43|a|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1
+| @43|b|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1
+| @41> |a|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1| 
+| +0#4040ff13&@39|╔+0#0000001#ffd7ff255|═@32|╗
+| +0#4040ff13#ffffff0@39|║+0#0000001#ffd7ff255| 
+0&#e0e0e08|a|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1| 
|║+0&#ffd7ff255
+| +0#4040ff13#ffffff0@39|║+0#0000001#ffd7ff255| 
|b|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1| |║
+| +0#4040ff13#ffffff0@39|╚+0#0000001#ffd7ff255|═@32|╝
+| +0#4040ff13#ffffff0@73|~
diff --git a/src/testdir/dumps/Test_popup_border_start_rtl_1_m.dump 
b/src/testdir/dumps/Test_popup_border_start_rtl_1_m.dump
new file mode 100644
index 000000000..0d8c5ed29
--- /dev/null
+++ b/src/testdir/dumps/Test_popup_border_start_rtl_1_m.dump
@@ -0,0 +1,8 @@
+| +0&#ffffff0@43|a|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1
+| @43|b|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1
+| @41> |a|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1| 
+| +0#4040ff13&@38| +0#0000001#ffd7ff255|╔|═@32|╗
+| +0#4040ff13#ffffff0@38| +0#0000001#ffd7ff255|║| 
+0&#e0e0e08|a|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1| 
|║+0&#ffd7ff255
+| +0#4040ff13#ffffff0@38| +0#0000001#ffd7ff255|║| 
|b|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1| |║
+| +0#4040ff13#ffffff0@38| +0#0000001#ffd7ff255|╚|═@32|╝
+| +0#4040ff13#ffffff0@73|~
diff --git a/src/testdir/dumps/Test_popup_border_start_rtl_2.dump 
b/src/testdir/dumps/Test_popup_border_start_rtl_2.dump
new file mode 100644
index 000000000..5799f7890
--- /dev/null
+++ b/src/testdir/dumps/Test_popup_border_start_rtl_2.dump
@@ -0,0 +1,8 @@
+| +0&#ffffff0@43|a|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1
+| @43|b|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1
+| @40> |a|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1| @1
+| +0#4040ff13&@39|╔+0#0000001#ffd7ff255|═@32|╗
+| +0#4040ff13#ffffff0@39|║+0#0000001#ffd7ff255| 
+0&#e0e0e08|a|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1| 
|║+0&#ffd7ff255
+| +0#4040ff13#ffffff0@39|║+0#0000001#ffd7ff255| 
|b|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1| |║
+| +0#4040ff13#ffffff0@39|╚+0#0000001#ffd7ff255|═@32|╝
+| +0#4040ff13#ffffff0@73|~
diff --git a/src/testdir/dumps/Test_popup_border_start_rtl_2_m.dump 
b/src/testdir/dumps/Test_popup_border_start_rtl_2_m.dump
new file mode 100644
index 000000000..e331f24e6
--- /dev/null
+++ b/src/testdir/dumps/Test_popup_border_start_rtl_2_m.dump
@@ -0,0 +1,8 @@
+| +0&#ffffff0@43|a|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1
+| @43|b|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1
+| @40> |a|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1| @1
+| +0#4040ff13&@38| +0#0000001#ffd7ff255|╔|═@32|╗
+| +0#4040ff13#ffffff0@38| +0#0000001#ffd7ff255|║| 
+0&#e0e0e08|a|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1| 
|║+0&#ffd7ff255
+| +0#4040ff13#ffffff0@38| +0#0000001#ffd7ff255|║| 
|b|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1| |║
+| +0#4040ff13#ffffff0@38| +0#0000001#ffd7ff255|╚|═@32|╝
+| +0#4040ff13#ffffff0@73|~
diff --git a/src/testdir/dumps/Test_popup_border_start_rtl_5.dump 
b/src/testdir/dumps/Test_popup_border_start_rtl_5.dump
new file mode 100644
index 000000000..6f81ec9cd
--- /dev/null
+++ b/src/testdir/dumps/Test_popup_border_start_rtl_5.dump
@@ -0,0 +1,8 @@
+| +0&#ffffff0@43|a|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1
+| @43|b|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1
+| @37> |a|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1| @4
+| +0#4040ff13&@36|╔+0#0000001#ffd7ff255|═@32|╗| +0#4040ff13#ffffff0@1|~
+| @36|║+0#0000001#ffd7ff255| 
+0&#e0e0e08|a|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1| 
|║+0&#ffd7ff255| +0#4040ff13#ffffff0@1|~
+| @36|║+0#0000001#ffd7ff255| 
|b|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1| |║| 
+0#4040ff13#ffffff0@1|~
+| @36|╚+0#0000001#ffd7ff255|═@32|╝| +0#4040ff13#ffffff0@1|~
+| @73|~
diff --git a/src/testdir/dumps/Test_popup_border_start_rtl_5_m.dump 
b/src/testdir/dumps/Test_popup_border_start_rtl_5_m.dump
new file mode 100644
index 000000000..485f049a5
--- /dev/null
+++ b/src/testdir/dumps/Test_popup_border_start_rtl_5_m.dump
@@ -0,0 +1,8 @@
+| +0&#ffffff0@43|a|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1
+| @43|b|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1
+| @37> |a|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1| @4
+| +0#4040ff13&@35| +0#0000001#ffd7ff255|╔|═@32|╗| | +0#4040ff13#ffffff0|~
+| @35| +0#0000001#ffd7ff255|║| 
+0&#e0e0e08|a|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1| 
|║+0&#ffd7ff255| | +0#4040ff13#ffffff0|~
+| @35| +0#0000001#ffd7ff255|║| 
|b|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1| |║| | 
+0#4040ff13#ffffff0|~
+| @35| +0#0000001#ffd7ff255|╚|═@32|╝| | +0#4040ff13#ffffff0|~
+| @73|~
diff --git a/src/testdir/dumps/Test_popup_position_03.dump 
b/src/testdir/dumps/Test_popup_position_03.dump
index 9b86f34e5..b26ca2d59 100644
--- a/src/testdir/dumps/Test_popup_position_03.dump
+++ b/src/testdir/dumps/Test_popup_position_03.dump
@@ -2,7 +2,7 @@
 |1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b| 
@5||+1&&|1+0&&|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|b| @5
 @12|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5||+1&&| 
+0&&@11|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5
 |6|7|8|9|_|a| @30||+1&&|6+0&&|7|8|9|_|a> @30
-|~+0#4040ff13&| @35||+1#0000000&|~+0#4040ff13&| @3| 
+0#0000001#e0e0e08|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|>
-|~+0#4040ff13#ffffff0| @35||+1#0000000&|~+0#4040ff13&| @3| 
+0#0000001#ffd7ff255|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|>
+|~+0#4040ff13&| @35||+1#0000000&|~+0#4040ff13&| @4| 
+0#0000001#e0e0e08|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|>
+|~+0#4040ff13#ffffff0| @35||+1#0000000&|~+0#4040ff13&| @4| 
+0#0000001#ffd7ff255|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|>
 |~+0#4040ff13#ffffff0| @35||+1#0000000&|~+0#4040ff13&| @35
 |~| @35||+1#0000000&|~+0#4040ff13&| @35
diff --git a/src/testdir/dumps/Test_pum_maxwidth_07.dump 
b/src/testdir/dumps/Test_pum_maxwidth_07.dump
index ada8acb0d..112e1f588 100644
--- a/src/testdir/dumps/Test_pum_maxwidth_07.dump
+++ b/src/testdir/dumps/Test_pum_maxwidth_07.dump
@@ -1,7 +1,7 @@
 |1+0&#ffffff0|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_|1|2|3|4|5|6|7|8|9|_> @44
 |1+0#0000001#e0e0e08|2|3|4|5|6|7|8|9|>| +0#4040ff13#ffffff0@64
 |一*0#0000001#ffd7ff255|二|三|四| +&|>| +0#4040ff13#ffffff0@64
-|a+0#0000001#ffd7ff255|b|c|d|e|f|g|h|i|>| +0#4040ff13#ffffff0@64
+|a+0#0000001#ffd7ff255|b|c|d|e|f|g|h|i|j| +0#4040ff13#ffffff0@64
 |上*0#0000001#ffd7ff255|下|左|右| +&@1| +0#4040ff13#ffffff0@64
 |~| @73
 |~| @73
diff --git a/src/testdir/dumps/Test_pum_maxwidth_08.dump 
b/src/testdir/dumps/Test_pum_maxwidth_08.dump
index aa41b76d1..9f92ae706 100644
--- a/src/testdir/dumps/Test_pum_maxwidth_08.dump
+++ b/src/testdir/dumps/Test_pum_maxwidth_08.dump
@@ -1,7 +1,7 @@
 | +0&#ffffff0@43> |_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1|_|9|8|7|6|5|4|3|2|1
 | +0#4040ff13&@64|<+0#0000001#e0e0e08|9|8|7|6|5|4|3|2|1
 | +0#4040ff13#ffffff0@64|<+0#0000001#ffd7ff255| |四*&|三|二|一
-| +0#4040ff13#ffffff0@64|<+0#0000001#ffd7ff255|i|h|g|f|e|d|c|b|a
+| +0#4040ff13#ffffff0@64|j+0#0000001#ffd7ff255|i|h|g|f|e|d|c|b|a
 | +0#4040ff13#ffffff0@64| +0#0000001#ffd7ff255@1|右*&|左|下|上
 | +0#4040ff13#ffffff0@73|~
 | @73|~
diff --git a/src/testdir/dumps/Test_pum_maxwidth_21.dump 
b/src/testdir/dumps/Test_pum_maxwidth_21.dump
index a94eb2fc4..53def2cfc 100644
--- a/src/testdir/dumps/Test_pum_maxwidth_21.dump
+++ b/src/testdir/dumps/Test_pum_maxwidth_21.dump
@@ -1,7 +1,7 @@
 |f+0&#ffffff0|o@1> @71
 |f+0#0000001#e0e0e08|o@1| @7|f|o@1|K|>| +0#4040ff13#ffffff0@58
 |b+0#0000001#ffd7ff255|a|r| @7|一*&|二|>+&| +0#4040ff13#ffffff0@58
-|一*0#0000001#ffd7ff255|二|三|四|五| +&|m|u|l|t|>| +0#4040ff13#ffffff0@58
+|一*0#0000001#ffd7ff255|二|三|四|五| +&|m|u|l|t|i| +0#4040ff13#ffffff0@58
 |~| @73
 |~| @73
 |~| @73
diff --git a/src/testdir/dumps/Test_pum_maxwidth_22.dump 
b/src/testdir/dumps/Test_pum_maxwidth_22.dump
index 573279785..fa95a1ead 100644
--- a/src/testdir/dumps/Test_pum_maxwidth_22.dump
+++ b/src/testdir/dumps/Test_pum_maxwidth_22.dump
@@ -1,7 +1,7 @@
 | +0&#ffffff0@70> |o@1|f
 | +0#4040ff13&@58|<+0#0000001#e0e0e08|K|o@1|f| @7|o@1|f
 | +0#4040ff13#ffffff0@58|<+0#0000001#ffd7ff255|二*&|一| +&@7|r|a|b
-| +0#4040ff13#ffffff0@58|<+0#0000001#ffd7ff255|t|l|u|m| |五*&|四|三|二|一
+| +0#4040ff13#ffffff0@58|i+0#0000001#ffd7ff255|t|l|u|m| |五*&|四|三|二|一
 | +0#4040ff13#ffffff0@73|~
 | @73|~
 | @73|~
diff --git a/src/testdir/test_highlight.vim b/src/testdir/test_highlight.vim
index 0c9eaebb1..c8d6e76ab 100644
--- a/src/testdir/test_highlight.vim
+++ b/src/testdir/test_highlight.vim
@@ -820,7 +820,7 @@ endfunc
 " Test for 'highlight' option
 func Test_highlight_opt()
   let save_hl = &highlight
-  call assert_fails('set highlight=j:b', 'E474:')
+  call assert_fails('set highlight=K:b', 'E474:')
   set highlight=f\ r
   call assert_equal('f r', &highlight)
   set highlight=fb
diff --git a/src/testdir/test_options.vim b/src/testdir/test_options.vim
index 9fe790c4e..363d93ea0 100644
--- a/src/testdir/test_options.vim
+++ b/src/testdir/test_options.vim
@@ -637,7 +637,7 @@ func Test_set_completion_string_values()
   set keyprotocol&
 
   " previewpopup / completepopup
-  call assert_equal('height:', getcompletion('set previewpopup=', 
'cmdline')[0])
+  call assert_equal('align:', getcompletion('set previewpopup=', 'cmdline')[0])
   call assert_equal('EndOfBuffer', getcompletion('set 
previewpopup=highlight:End*Buffer', 'cmdline')[0])
   call feedkeys(":set previewpopup+=border:\<Tab>\<C-B>\"\<CR>", 'xt')
   call assert_equal('"set previewpopup+=border:on', @:)
diff --git a/src/testdir/test_popup.vim b/src/testdir/test_popup.vim
index fac2a7592..f88cac29e 100644
--- a/src/testdir/test_popup.vim
+++ b/src/testdir/test_popup.vim
@@ -842,7 +842,7 @@ func Test_popup_position()
                 123
   END
   call writefile(lines, 'Xtest', 'D')
-  let buf = RunVimInTerminal('Xtest', {})
+  let buf = RunVimInTerminal('Xtest', {'cols': 75})
   call term_sendkeys(buf, ":vsplit\<CR>")
 
   " default pumwidth in left window: overlap in right window
@@ -971,10 +971,24 @@ func Test_mouse_popup_position()
   call VerifyScreenDump(buf, 'Test_mouse_popup_position_01', {})
   call term_sendkeys(buf, "\<Esc>")
 
+  call term_sendkeys(buf, ":set pumborder=double,margin,shadow\<CR>")
+  call term_sendkeys(buf, ":call Trigger(45)\<CR>")
+  call TermWait(buf, 30)
+  call VerifyScreenDump(buf, 'Test_mouse_popup_position_02', {})
+  call term_sendkeys(buf, "\<Esc>")
+  call term_sendkeys(buf, ":set pumborder=\<CR>")
+
   if has('rightleft')
     call term_sendkeys(buf, ":set rightleft\<CR>")
     call term_sendkeys(buf, ":call Trigger(50 + 1 - 45)\<CR>")
-    call VerifyScreenDump(buf, 'Test_mouse_popup_position_02', {})
+    call VerifyScreenDump(buf, 'Test_mouse_popup_position_03', {})
+
+    call term_sendkeys(buf, ":set pumborder=ascii,margin,shadow\<CR>")
+    call term_sendkeys(buf, ":call Trigger(50 + 1 - 45)\<CR>")
+    call TermWait(buf, 30)
+    call VerifyScreenDump(buf, 'Test_mouse_popup_position_04', {})
+    call term_sendkeys(buf, ":set pumborder=\<CR>")
+
     call term_sendkeys(buf, "\<Esc>:set norightleft\<CR>")
   endif
 
@@ -2294,4 +2308,81 @@ func Test_popup_complete_cmdwin_preview()
   set omnifunc&
 endfunc
 
+func Test_popup_border()
+  CheckScreendump
+
+  let lines =<< trim END
+    123456789_123456789_123456789_a
+    123456789_123456789_123456789_b
+
+  END
+  call writefile(lines, 'Xtest', 'D')
+  let buf = RunVimInTerminal('Xtest', {'cols': 75})
+
+  func TestPumPosition(buf, spaces, dumpfile)
+    call term_sendkeys(a:buf, $"GS{repeat(' ', a:spaces)}1\<C-N>")
+    call TermWait(a:buf, 10)
+    call VerifyScreenDump(a:buf, a:dumpfile, {'rows': 8})
+    call term_sendkeys(a:buf, "\<Esc>u")
+  endfunc
+
+  func TestPumPositionStart(buf, spaces, dumpfile)
+    call term_sendkeys(a:buf, ":set pumborder=double\<CR>")
+    call TestPumPosition(a:buf, a:spaces, a:dumpfile)
+    call term_sendkeys(a:buf, ":set pumborder=double,margin\<CR>")
+    call TestPumPosition(a:buf, a:spaces, $'{a:dumpfile}_m')
+  endfunc
+
+  " pum starts at the edge
+  for space_count in [0, 1, 2, 5]
+    call TestPumPositionStart(buf, space_count,
+          \ $'Test_popup_border_start_{space_count}')
+  endfor
+
+  if has('rightleft')
+    call term_sendkeys(buf, ":set rightleft\<CR>")
+    for space_count in [0, 1, 2, 5]
+      call TestPumPositionStart(buf, space_count,
+            \ $'Test_popup_border_start_rtl_{space_count}')
+    endfor
+    call term_sendkeys(buf, "\<Esc>:set norightleft\<CR>")
+  endif
+
+  " pum ends at the edge
+  call term_sendkeys(buf, ":vsplit\<CR>")
+  call term_sendkeys(buf, "\<C-W>l")
+  for i in range(2)
+    let rtl = ''
+    if i == 1 && has('rightleft')
+      call term_sendkeys(buf, "\<C-W>h")
+      call term_sendkeys(buf, ":set rightleft\<CR>")
+      let rtl = 'rtl_'
+    endif
+
+    call term_sendkeys(buf, ":set pumborder=double\<CR>")
+    for space_count in [5, 6, 20, 21, 22]
+      call TestPumPosition(buf, space_count,
+            \ $'Test_popup_border_end_{rtl}{space_count}')
+    endfor
+
+    call term_sendkeys(buf, ":set pumborder=double,margin\<CR>")
+    for space_count in [4, 5, 19, 20, 21]
+      call TestPumPosition(buf, space_count,
+            \ $'Test_popup_border_end_{rtl}m_{space_count}')
+    endfor
+
+    call term_sendkeys(buf, ":set pumborder=double,margin,shadow\<CR>")
+    for space_count in [2, 3, 17, 18, 19]
+      call TestPumPosition(buf, space_count,
+            \ $'Test_popup_border_end_{rtl}m_s_{space_count}')
+    endfor
+
+    if i == 1 && has('rightleft')
+      call term_sendkeys(buf, "\<Esc>:set norightleft\<CR>")
+    endif
+  endfor
+
+  call StopVimInTerminal(buf)
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/testdir/util/gen_opt_test.vim 
b/src/testdir/util/gen_opt_test.vim
index 56ce92171..0c02d7d5e 100644
--- a/src/testdir/util/gen_opt_test.vim
+++ b/src/testdir/util/gen_opt_test.vim
@@ -282,6 +282,10 @@ let test_values = {
       \                ['xxx', 'xxx,c:yes', 'xxx:', 'xxx:,c:yes']],
       \ 'printoptions': [['', 'header:0', 'left:10pc,top:5pc'],
       \                ['xxx', 'header:-1']],
+      \ 'pumborder': [['', 'single', 'double', 'round', 'ascii', 'shadow',
+      \                'double,margin,shadow', 'custom:─;│;─;│;┌;┐;┘;└,shadow',
+      \                'ascii,margin'],
+      \                ['xxx', 'margin', 'margin,shadow', 'custom:', 
'custom:+;']],
       \ 'renderoptions': [[''], ['xxx']],
       \ 'rightleftcmd': [['search'], ['xxx']],
       \ 'rulerformat': [['', 'xxx'], ['%-', '%(', '%15(%%']],
diff --git a/src/version.c b/src/version.c
index 31f608084..987c00fa8 100644
--- a/src/version.c
+++ b/src/version.c
@@ -729,6 +729,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1835,
 /**/
     1834,
 /**/
diff --git a/src/vim.h b/src/vim.h
index 3c4dacb44..dc7fc09c9 100644
--- a/src/vim.h
+++ b/src/vim.h
@@ -1574,6 +1574,8 @@ typedef enum
     , HLF_PSX      // popup menu selected item "menu" (extra text)
     , HLF_PSB      // popup menu scrollbar
     , HLF_PST      // popup menu scrollbar thumb
+    , HLF_PMB      // popup menu border
+    , HLF_PMS      // popup menu shadow
     , HLF_TP       // tabpage line
     , HLF_TPS      // tabpage line selected
     , HLF_TPF      // tabpage line filler
@@ -1597,7 +1599,7 @@ typedef enum
                  'n', 'a', 'b', 'N', 'G', 'O', 'r', 's', 'S', 'c', 't', 'v', 
'V', \
                  'w', 'W', 'f', 'F', 'A', 'C', 'D', 'T', 'E', '-', '>', \
                  'B', 'P', 'R', 'L', \
-                 '+', '=', 'k', '<','[', ']', '{', '}', 'x', 'X', \
+                 '+', '=', 'k', '<','[', ']', '{', '}', 'x', 'X', 'j', 'H', \
                  '*', '#', '_', '!', '.', 'o', 'q', \
                  'z', 'Z', 'g', \
                  '%', '^', '&', 'I'}

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/vim_dev/E1v6En5-000Xx0-5n%40256bit.org.

Raspunde prin e-mail lui