Skip to content

fix SHIFT-Insert on Windows command prompt#2381

Closed
mattn wants to merge 1 commit into
vim:masterfrom
mattn:fix-shift-insert-win32con
Closed

fix SHIFT-Insert on Windows command prompt#2381
mattn wants to merge 1 commit into
vim:masterfrom
mattn:fix-shift-insert-win32con

Conversation

@mattn

@mattn mattn commented Nov 28, 2017

Copy link
Copy Markdown
Member

This is fixing for a bug which vim.exe doesn't accept SHIFT-INSERT.

https://groups.google.com/forum/#!topic/vim_use/G1hB7FJbyAo/discussion

When patch 7.4.852 was included, combination of K_NUL & ANSI keys was not handled. And it was converted to unicode.

https://groups.google.com/forum/#!topic/vim_dev/Gu7pDIjS1UE/discussion

		if (ch2 != NUL)
		{
		    typeahead[typeaheadlen + n] = 3;
		    typeahead[typeaheadlen + n + 1] = (char_u)ch2;
		    n += 2;
		}

For example, following part use K_NUL & ANSI key to handle SHIFT-INSERT.

vim/src/os_win32.c

Lines 989 to 1013 in bdb8139

for (i = sizeof(VirtKeyMap) / sizeof(VirtKeyMap[0]); --i >= 0; )
{
if (VirtKeyMap[i].wVirtKey == pker->wVirtualKeyCode)
{
if (nModifs == 0)
*pch = VirtKeyMap[i].chAlone;
else if ((nModifs & SHIFT) != 0 && (nModifs & ~SHIFT) == 0)
*pch = VirtKeyMap[i].chShift;
else if ((nModifs & CTRL) != 0 && (nModifs & ~CTRL) == 0)
*pch = VirtKeyMap[i].chCtrl;
else if ((nModifs & ALT) != 0 && (nModifs & ~ALT) == 0)
*pch = VirtKeyMap[i].chAlt;
if (*pch != 0)
{
if (VirtKeyMap[i].fAnsiKey)
{
*pch2 = *pch;
*pch = K_NUL;
}
return TRUE;
}
}
}

This change handle K_NUL in leading-character.

@codecov-io

codecov-io commented Nov 28, 2017

Copy link
Copy Markdown

Codecov Report

Merging #2381 into master will increase coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2381      +/-   ##
==========================================
+ Coverage   74.52%   74.54%   +0.01%     
==========================================
  Files          91       91              
  Lines      132415   132422       +7     
  Branches    29083    30807    +1724     
==========================================
+ Hits        98686    98717      +31     
- Misses      33700    33705       +5     
+ Partials       29        0      -29
Impacted Files Coverage Δ
src/version.c 81.81% <ø> (ø) ⬆️
src/edit.c 85.32% <100%> (ø) ⬆️
src/quickfix.c 92.5% <100%> (+0.14%) ⬆️
src/ex_getln.c 73.11% <100%> (ø) ⬆️
src/if_xcmdsrv.c 83.63% <0%> (-0.54%) ⬇️
src/gui.c 47.5% <0%> (-0.16%) ⬇️
src/term.c 50.72% <0%> (-0.06%) ⬇️
src/eval.c 80.96% <0%> (-0.05%) ⬇️
src/syntax.c 77.51% <0%> (-0.03%) ⬇️
src/channel.c 82.48% <0%> (+0.12%) ⬆️
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bdb8139...aeae41d. Read the comment docs.

@mattn

mattn commented Nov 28, 2017

Copy link
Copy Markdown
Member Author

Sorry, this break something. For example, <up> key doesn't work.

@brammool brammool closed this in 3660a10 Nov 28, 2017
@mattn

mattn commented Nov 28, 2017

Copy link
Copy Markdown
Member Author

@brammool This should not be merged since this PR is still wrong. As I mentioned in above, <Up> doesn't work.

@mattn

mattn commented Nov 29, 2017

Copy link
Copy Markdown
Member Author

@chrisbra @k-takata Could please reopen this?

@k-takata k-takata reopened this Nov 29, 2017
@mattn mattn force-pushed the fix-shift-insert-win32con branch from aeae41d to 80e142e Compare November 29, 2017 07:22
@mattn

mattn commented Nov 29, 2017

Copy link
Copy Markdown
Member Author

Fixed. I checked this on vim.exe with utf-8 and cp932.

@brammool brammool closed this in feeb4d0 Dec 5, 2017
adizero pushed a commit to adizero/vim that referenced this pull request May 19, 2018
Problem:    Shift-Insert doesn't always work in MS-Windows console.
Solution:   Handle K_NUL differently. (Yasuhiro Matsumoto, closes vim#2381)
adizero pushed a commit to adizero/vim that referenced this pull request May 19, 2018
Problem:    Shift-Insert doesn't always work in MS-Windows console.
Solution:   Handle K_NUL differently if the second character is more than one
            byte. (Yasuhiro Matsumoto, closes vim#2381)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants