Skip to content

Commit 220f87b

Browse files
author
Yatao Li
committed
do not cursor goto msg window position 0,0
1 parent 5190942 commit 220f87b

File tree

2 files changed

+32
-15
lines changed

2 files changed

+32
-15
lines changed

ViewModels/GridViewModel.fs

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ and GridViewModel(_gridid: int, ?_parent: GridViewModel, ?_gridsize: GridSize) a
7878
let mutable m_is_external = false
7979
let mutable m_is_float = false
8080
let mutable m_is_msg = false
81+
let mutable _m_msg_win_row = 0
82+
let mutable _m_is_msg_root = false
8183
let mutable m_msg_scrolled = false
8284
let mutable m_msg_sepchar = ""
8385
let mutable m_z = -100
@@ -372,6 +374,8 @@ and GridViewModel(_gridid: int, ?_parent: GridViewModel, ?_gridsize: GridSize) a
372374
m_msg_scrolled <- scrolled
373375
m_msg_sepchar <- sep_char
374376
m_z <- 9999 // always put msg window on the top
377+
let r, _ = this.AbsAnchor
378+
getRootGrid().SetMsgWinRow r // notify root about our position
375379

376380
// example:
377381
// editorvm #5: setWinFloatPos: r = 51.000000 c = 0.000000 z = 50 anchor = SouthWest anchor_grid = 1
@@ -622,29 +626,36 @@ and GridViewModel(_gridid: int, ?_parent: GridViewModel, ?_gridsize: GridSize) a
622626
if id = _gridid then
623627
m_cursor_vm.row <- row
624628
m_cursor_vm.col <- col
629+
// do not move to msg window 1st character
625630
// translation back to parent
626631
if m_parent.IsSome then
627-
#if DEBUG
628-
trace _gridid "CursorGoto parent"
629-
#endif
632+
#if DEBUG
633+
trace _gridid "CursorGoto: %d %d %d -> parent" id row col
634+
#endif
630635
let rr, rc = this.RelAnchor
631636
m_parent.Value.CursorGoto m_parent.Value.GridId (row + rr) (col + rc)
632-
// goto me
637+
// goto me (a top-level grid)
633638
else
634-
#if DEBUG
635-
trace _gridid "CursorGoto me"
636-
#endif
637-
m_cursor_vm.focused <- true
638-
this.IsFocused <- true
639-
this.CursorConfig()
639+
if _m_is_msg_root && row = _m_msg_win_row && col = 0 then
640+
#if DEBUG
641+
trace _gridid "CursorGoto: %d %d %d -> root msg ignore" id row col
642+
#endif
643+
()
644+
else
645+
#if DEBUG
646+
trace _gridid "CursorGoto: %d %d %d -> me" id row col
647+
#endif
648+
m_cursor_vm.focused <- true
649+
this.IsFocused <- true
650+
this.CursorConfig()
640651
// goto my child
641652
elif m_child_grids.FindIndex(fun x -> x.GridId = id) > -1 then
642653
()
643654
// was me, but not anymore
644655
elif m_cursor_vm.focused then
645-
#if DEBUG
646-
trace _gridid "CursorGoto notme"
647-
#endif
656+
#if DEBUG
657+
trace _gridid "CursorGoto: %d %d %d notme" id row col
658+
#endif
648659
m_cursor_vm.focused <- false
649660
m_cursor_vm.RenderTick <- m_cursor_vm.RenderTick + 1
650661

@@ -843,6 +854,9 @@ and GridViewModel(_gridid: int, ?_parent: GridViewModel, ?_gridsize: GridSize) a
843854
member __.ScrollbarData = m_scrollbar_top,m_scrollbar_bot,m_scrollbar_row,m_scrollbar_col,m_scrollbar_linecount
844855
member __.IsFloat = m_is_float
845856
member __.IsMsg = m_is_msg
857+
member __.SetMsgWinRow x =
858+
_m_msg_win_row <- x
859+
_m_is_msg_root <- true
846860
member __.BufNr = m_bufnr
847861
member __.Extmarks = m_extmarks
848862
member __.ExtmarksOob = m_extmarks_oob

wcwidth.fs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ module FVim.wcwidth
66

77
open def
88
open common
9+
open log
910

1011
// From https://github.com/jquast/wcwidth/blob/master/wcwidth/table_zero.py
1112
// at commit 0d7de112202cc8b2ebe9232ff4a5c954f19d561a (2016-07-02):
@@ -560,8 +561,10 @@ let private _wcwidth_impl =
560561
| x when intable ZeroWidth x -> CharType.Invisible
561562
// Braille patterns
562563
| x when 0x2800u <= x && x <= 0x28FFu -> CharType.Braille
563-
| _ ->
564-
(*trace "wcwidth" "unknown codepoint: %c (%X)" (char ucs) (ucs)*)
564+
| ucs ->
565+
#if DEBUG
566+
trace "wcwidth" "unknown codepoint: %c (%X)" (char ucs) (ucs)
567+
#endif
565568
CharType.Narrow
566569

567570
let wcwidth(ucs: uint) =

0 commit comments

Comments
 (0)