Makes all tests pass on Windows (#1939)

* appveyor config v1

* typo

* choco failing - getting more info

* force install?

* ignore dependencies

* Dot at the end makes it more obvious what the whole value is

* reducing verbosity

* fixed read shell command test #1914

special case for win32 + neovim

* forgot to remove .only

* taking care of the '\r' dangling on lines on win32 #1914

* \\n doesn't translate to new-line on Windows. \\r\\n does

fixing failed test 4 of #1914

* prettified the code
This commit is contained in:
Philip Mateescu 2017-08-13 00:38:56 -05:00 committed by Horace He
parent 9925a7edfc
commit 6b702872e7
4 changed files with 35 additions and 3 deletions

16
appveyor.yml Normal file
View File

@ -0,0 +1,16 @@
environment:
node_version: "6.11.1"
PATH: c:\tools\neovim\Neovim\bin;$(PATH)
install:
- ps: Install-Product node $env:node_version
- choco install neovim --pre -fy --ignoredependencies
- npm install -g gulp
- npm install
build_script:
- gulp
test_script:
- nvim --version
- npm test --silent

View File

@ -76,6 +76,12 @@ export class Neovim {
static async syncVimToVs(vimState: VimState) {
const nvim = vimState.nvim;
const buf = await nvim.getCurrentBuf();
const lines = await buf.getLines(0, -1, false);
// one Windows, lines that went to nvim and back have a '\r' at the end,
// which causes the issues exhibited in #1914
const fixedLines =
process.platform === 'win32' ? lines.map((line, index) => line.replace(/\r$/, '')) : lines;
await TextEditor.replace(
new vscode.Range(
@ -84,9 +90,11 @@ export class Neovim {
TextEditor.getLineCount() - 1,
TextEditor.getLineMaxColumn(TextEditor.getLineCount() - 1)
),
(await buf.getLines(0, -1, false)).join('\n')
fixedLines.join('\n')
);
console.log(`${lines.length} lines in nvime but ${TextEditor.getLineCount()} in editor.`);
let [row, character] = ((await nvim.callFunction('getpos', ['.'])) as Array<number>).slice(
1,
3

View File

@ -3,6 +3,7 @@ import {
setTextEditorOptions,
cleanUpWorkspace,
assertEqual,
crossPlatformIt,
} from './../testUtils';
import { ModeName } from '../../src/mode/mode';
import { ModeHandler } from '../../src/mode/modeHandler';
@ -1485,14 +1486,14 @@ suite('Mode Normal', () => {
newTest({
title: '/ can search with newline',
start: ['|asdf', '__asdf', 'asdf'],
keysPressed: '/\\nasdf\n',
keysPressed: crossPlatformIt('/\\nasdf\n'),
end: ['asdf', '__asd|f', 'asdf'],
});
newTest({
title: '/ can search through multiple newlines',
start: ['|asdf', '__asdf', 'asdf', 'abc', ' abc'],
keysPressed: '/asdf\\nasdf\\nabc\n',
keysPressed: crossPlatformIt('/asdf\\nasdf\\nabc\n'),
end: ['asdf', '__|asdf', 'asdf', 'abc', ' abc'],
});

View File

@ -96,3 +96,10 @@ export function setTextEditorOptions(tabSize: number, insertSpaces: boolean): vo
options.insertSpaces = insertSpaces;
vscode.window.activeTextEditor!.options = options;
}
export function crossPlatformIt(text: string): string {
if (process.platform === 'win32') {
return text.replace(/\\n/g, '\\r\\n');
}
return text;
}