Compare commits

..

5 Commits

Author SHA1 Message Date
Kyle Carberry
2bc6e1a457 Fix clipboard pasting 2019-04-22 20:20:48 -04:00
Kyle Carberry
e61ea796c6 Bundle grammars (#563) 2019-04-22 12:51:05 -05:00
Kyle Carberry
d073622629 Add --socket flag (#564)
* Add --socket flag

* Add msg for already bound socket
2019-04-22 12:47:27 -05:00
Kyle Carberry
5f40ebb845 Update wording for sshcode 2019-04-19 21:22:00 -04:00
Kyle Carberry
c56e2797cc Add sshcode to the readme 2019-04-19 21:20:31 -04:00
4 changed files with 69 additions and 15 deletions

View File

@@ -23,6 +23,10 @@ docker run -it -p 127.0.0.1:8443:8443 -v "${PWD}:/home/coder/project" codercom/c
## Getting Started
### Run over SSH
Use [sshcode](https://github.com/codercom/sshcode) for a simple setup.
### Docker
See docker oneliner mentioned above. Dockerfile is at [/Dockerfile](/Dockerfile).

View File

@@ -30,6 +30,7 @@ commander.version(process.env.VERSION || "development")
.option("-H, --allow-http", "Allow http connections.", false)
.option("-P, --password <value>", "DEPRECATED: Use the PASSWORD environment variable instead. Specify a password for authentication.")
.option("--disable-telemetry", "Disables ALL telemetry.", false)
.option("--socket <value>", "Listen on a UNIX socket. Host and port will be ignored when set.")
.option("--install-extension <value>", "Install an extension by its ID.")
.option("--bootstrap-fork <name>", "Used for development. Never set.")
.option("--extra-args <args>", "Used for development. Never set.")
@@ -63,6 +64,7 @@ const bold = (text: string | number): string | number => {
readonly open?: boolean;
readonly cert?: string;
readonly certKey?: string;
readonly socket?: string;
readonly installExtension?: string;
@@ -267,7 +269,11 @@ const bold = (text: string | number): string | number => {
});
logger.info("Starting webserver...", field("host", options.host), field("port", options.port));
app.server.listen(options.port, options.host);
if (options.socket) {
app.server.listen(options.socket);
} else {
app.server.listen(options.port, options.host);
}
let clientId = 1;
app.wss.on("connection", (ws, req) => {
const id = clientId++;
@@ -284,7 +290,11 @@ const bold = (text: string | number): string | number => {
});
app.wss.on("error", (err: NodeJS.ErrnoException) => {
if (err.code === "EADDRINUSE") {
logger.error(`Port ${bold(options.port)} is in use. Please free up port ${options.port} or specify a different port with the -p flag`);
if (options.socket) {
logger.error(`Socket ${bold(options.socket)} is in use. Please specify a different socket.`);
} else {
logger.error(`Port ${bold(options.port)} is in use. Please free up port ${options.port} or specify a different port with the -p flag`);
}
process.exit(1);
}
});

View File

@@ -2,6 +2,17 @@ import * as vscodeTextmate from "../../../../lib/vscode/node_modules/vscode-text
const target = vscodeTextmate as typeof vscodeTextmate;
const ctx = (require as any).context("../../../../lib/extensions", true, /.*\.tmLanguage.json$/);
// Maps grammar scope to loaded grammar
const scopeToGrammar = {} as any;
ctx.keys().forEach((key: string) => {
const value = ctx(key);
if (value.scopeName) {
scopeToGrammar[value.scopeName] = value;
}
});
target.Registry = class Registry extends vscodeTextmate.Registry {
public constructor(opts: vscodeTextmate.RegistryOptions) {
super({
@@ -21,6 +32,13 @@ target.Registry = class Registry extends vscodeTextmate.Registry {
}).catch(reason => rej(reason));
});
},
loadGrammar: async (scopeName: string) => {
if (scopeToGrammar[scopeName]) {
return scopeToGrammar[scopeName];
}
return opts.loadGrammar(scopeName);
},
});
}
};

View File

@@ -175,7 +175,7 @@ index 1f8b17a..2a875f9 100644
+ await cli.main(args);
+ return; // Always just do this for now.
diff --git a/src/vs/editor/browser/config/configuration.ts b/src/vs/editor/browser/config/configuration.ts
index f97a692..0206957 100644
index f97a692..8059a67 100644
--- a/src/vs/editor/browser/config/configuration.ts
+++ b/src/vs/editor/browser/config/configuration.ts
@@ -10 +9,0 @@ import { Disposable } from 'vs/base/common/lifecycle';
@@ -187,9 +187,6 @@ index f97a692..0206957 100644
@@ -367 +366 @@ export class Configuration extends CommonEditorConfiguration {
- if (platform.isMacintosh) {
+ if (browser.isMacintosh) {
@@ -378 +377 @@ export class Configuration extends CommonEditorConfiguration {
- emptySelectionClipboard: browser.isWebKit || browser.isFirefox,
+ emptySelectionClipboard: false, // browser.isWebKit || browser.isFirefox,
diff --git a/src/vs/editor/browser/controller/mouseHandler.ts b/src/vs/editor/browser/controller/mouseHandler.ts
index b3b4472..f888d63 100644
--- a/src/vs/editor/browser/controller/mouseHandler.ts
@@ -250,32 +247,57 @@ index c69ea3f..b8d87f7 100644
-const GOLDEN_LINE_HEIGHT_RATIO = platform.isMacintosh ? 1.5 : 1.35;
+const GOLDEN_LINE_HEIGHT_RATIO = browser.isMacintosh ? 1.5 : 1.35;
diff --git a/src/vs/editor/contrib/clipboard/clipboard.ts b/src/vs/editor/contrib/clipboard/clipboard.ts
index 990be3a..8a326c6 100644
index 990be3a..4bec789 100644
--- a/src/vs/editor/contrib/clipboard/clipboard.ts
+++ b/src/vs/editor/contrib/clipboard/clipboard.ts
@@ -29 +29,2 @@ const supportsCopyWithSyntaxHighlighting = (supportsCopy && !browser.isEdgeOrIE)
@@ -18,0 +19 @@ import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegis
+import { clipboard } from 'electron';
@@ -29 +30,2 @@ const supportsCopyWithSyntaxHighlighting = (supportsCopy && !browser.isEdgeOrIE)
-const supportsPaste = (platform.isNative || (!browser.isChrome && document.queryCommandSupported('paste')));
+// const supportsPaste = (platform.isNative || (!browser.isChrome && document.queryCommandSupported('paste')));
+const supportsPaste = true;
@@ -176,0 +178 @@ class ExecCommandPasteAction extends ExecCommandAction {
@@ -54,0 +57 @@ abstract class ExecCommandAction extends EditorAction {
+ console.log(document.activeElement!.cloneNode(true));
@@ -71 +74 @@ class ExecCommandCutAction extends ExecCommandAction {
- kbOpts = null;
+ // kbOpts = null;
@@ -119 +122 @@ class ExecCommandCopyAction extends ExecCommandAction {
- kbOpts = null;
+ // kbOpts = null;
@@ -174 +177 @@ class ExecCommandPasteAction extends ExecCommandAction {
- kbOpts = null;
+ // kbOpts = null;
@@ -176,0 +180 @@ class ExecCommandPasteAction extends ExecCommandAction {
+ const { workbench } = require('vs/../../../../packages/vscode/src/workbench') as typeof import ('vs/../../../../packages/vscode/src/workbench');
@@ -181 +183 @@ class ExecCommandPasteAction extends ExecCommandAction {
@@ -181 +185 @@ class ExecCommandPasteAction extends ExecCommandAction {
- precondition: EditorContextKeys.writable,
+ precondition: (require('vs/platform/contextkey/common/contextkey') as typeof import('vs/platform/contextkey/common/contextkey')).ContextKeyExpr.and(EditorContextKeys.writable, workbench.clipboardContextKey),
@@ -191 +193,2 @@ class ExecCommandPasteAction extends ExecCommandAction {
@@ -191 +195,2 @@ class ExecCommandPasteAction extends ExecCommandAction {
- order: 3
+ order: 3,
+ when: workbench.clipboardContextKey,
@@ -194,0 +198,14 @@ class ExecCommandPasteAction extends ExecCommandAction {
@@ -194,0 +200,26 @@ class ExecCommandPasteAction extends ExecCommandAction {
+
+ public async run(accessor, editor: ICodeEditor): Promise<void> {
+ if (editor instanceof (require('vs/editor/browser/widget/codeEditorWidget') as typeof import('vs/editor/browser/widget/codeEditorWidget')).CodeEditorWidget) {
+ try {
+ editor.trigger('', (require('vs/editor/common/editorCommon') as typeof import ('vs/editor/common/editorCommon')).Handler.Paste, {
+ text: await (require('vs/../../../../packages/vscode/src/workbench') as typeof import ('vs/../../../../packages/vscode/src/workbench')).workbench.clipboardText,
+ editor.focus();
+ const textInput = document.activeElement! as HTMLTextAreaElement;
+ const dataTransfer = new DataTransfer();
+ const value = await clipboard.readText();
+ dataTransfer.setData("text/plain", value);
+ const pasteEvent = new ClipboardEvent("paste", {
+ clipboardData: dataTransfer,
+ });
+ textInput.dispatchEvent(pasteEvent);
+ } catch (ex) {
+ super.run(accessor, editor);
+ try {
+ editor.trigger('', (require('vs/editor/common/editorCommon') as typeof import ('vs/editor/common/editorCommon')).Handler.Paste, {
+ text: await (require('vs/../../../../packages/vscode/src/workbench') as typeof import ('vs/../../../../packages/vscode/src/workbench')).workbench.clipboardText,
+ });
+ } catch (ex) {
+ super.run(accessor, editor);
+ }
+ }
+ } else {
+ super.run(accessor, editor);