change system clipboard library to a newer more maintained library to try and resolve UTF-8 and chinese character issues

This commit is contained in:
xconverge 2017-04-09 11:50:07 -07:00
parent 0e7d80aaa1
commit 97e016d186
6 changed files with 15 additions and 40 deletions

View File

@ -9,7 +9,7 @@ os:
addons:
apt:
packages:
- xclip
- xsel
language: node_js

View File

@ -183,7 +183,7 @@ Or bind `<leader>w` to save the current file:
#### useSystemClipboard
* Enable yanking to the system clipboard by default
* Type: Boolean (Default: `false`)
* Note: Linux users must have xclip installed
* Note: Linux users must have xsel installed
#### searchHighlightColor
* Set the color of search highlights.

View File

@ -400,7 +400,7 @@
"postinstall": "node ./node_modules/vscode/bin/install && gulp init"
},
"dependencies": {
"copy-paste": "^1.3.0",
"clipboardy": "^1.1.0",
"diff-match-patch": "^1.0.0",
"lodash": "^4.12.0",
"color": "^1.0.3",

View File

@ -20,8 +20,8 @@ import { EasyMotion } from './../easymotion/easymotion';
import { FileCommand } from './../cmd_line/commands/file';
import { QuitCommand } from './../cmd_line/commands/quit';
import * as vscode from 'vscode';
import * as clipboard from 'copy-paste';
const clipboardy = require('clipboardy');
const is2DArray = function<T>(x: any): x is T[][] {
return Array.isArray(x[0]);
@ -1540,9 +1540,7 @@ class CommandCtrlVInSearchMode extends BaseCommand {
public async exec(position: Position, vimState: VimState): Promise<VimState> {
const searchState = vimState.globalState.searchState!;
const textFromClipboard = await new Promise<string>((resolve, reject) =>
clipboard.paste((err, text) => err ? reject(err) : resolve(text))
);
const textFromClipboard = clipboardy.readSync();
searchState.searchString += textFromClipboard;
return vimState;
@ -1557,9 +1555,7 @@ class CommandCmdVInSearchMode extends BaseCommand {
public async exec(position: Position, vimState: VimState): Promise<VimState> {
const searchState = vimState.globalState.searchState!;
const textFromClipboard = await new Promise<string>((resolve, reject) =>
clipboard.paste((err, text) => err ? reject(err) : resolve(text))
);
const textFromClipboard = clipboardy.readSync();
searchState.searchString += textFromClipboard;
return vimState;
@ -1608,15 +1604,7 @@ class CommandOverrideCopy extends BaseCommand {
text += line + '\n';
}
}
clipboard.copy(text, (err) => {
if (err) {
vscode.window.showErrorMessage(`Error copying to clipboard.
If you are on Linux, try installing xclip. If that doesn't work, set
vim.overrideCopy to be false to get subpar behavior. And make some
noise on VSCode's issue #217 if you want this fixed.`);
}
});
clipboardy.writeSync(text);
return vimState;
}

View File

@ -1,7 +1,7 @@
import { VimState, RecordedState } from './../mode/modeHandler';
import * as clipboard from 'copy-paste';
import { YankOperator, CommandYankFullLine, BaseOperator, BaseCommand, CommandRegister, DeleteOperator } from './../actions/actions';
import * as vscode from "vscode";
const clipboardy = require('clipboardy');
/**
* There are two different modes of copy/paste in Vim - copy by character
@ -137,7 +137,7 @@ export class Register {
}
clipboardText = clipboardText.replace(/\n$/, "");
clipboard.copy(clipboardText);
clipboardy.writeSync(clipboardText);
}
Register.ProcessNumberedRegister(registerContent.text, vimState);
@ -192,11 +192,7 @@ export class Register {
*/
private static putNormalRegister(content: RegisterContent, register: string, vimState: VimState): void {
if (Register.isClipboardRegister(register)) {
clipboard.copy(content, (err) => {
if (err) {
vscode.window.showErrorMessage("Error yanking, if useSystemClipboard is true and you are using Linux, please install xclip.");
}
});
clipboardy.writeSync(content);
}
Register.registers[register.toLowerCase()] = {
@ -245,7 +241,7 @@ export class Register {
}
if (Register.isClipboardRegister(register)) {
clipboard.copy(content);
clipboardy.writeSync(content);
}
Register.registers[register] = {
@ -316,16 +312,7 @@ export class Register {
/* Read from system clipboard */
if (Register.isClipboardRegister(register)) {
let text = await new Promise<string>((resolve, reject) =>
clipboard.paste((err, text) => {
if (err) {
vscode.window.showErrorMessage("Error pasting, if useSystemClipboard is true and you are using Linux, please install xclip.");
reject(err);
} else {
resolve(text);
}
})
);
let text = clipboardy.readSync();
// Harmonize newline character
text = text.replace(/\r\n/g, '\n');

View File

@ -4,7 +4,6 @@ import * as vscode from 'vscode';
import { ModeHandler } from "../../src/mode/modeHandler";
import { setupWorkspace, cleanUpWorkspace, assertEqualLines } from '../testUtils';
import { getTestingFunctions } from '../testSimplifier';
import * as clipboard from 'copy-paste';
suite("register", () => {
let modeHandler: ModeHandler;
@ -28,7 +27,8 @@ suite("register", () => {
end: ["two", "|one"],
});
clipboard.copy("12345");
const clipboardy = require('clipboardy');
clipboardy.writeSync("12345");
newTest({
title: "Can access '*' (clipboard) register",