Example #1
0
	client.onReady().then(() => {
		disposable = client.onTelemetry(e => {
			if (telemetryReporter) {
				telemetryReporter.sendTelemetryEvent(e.key, e.data);
			}
		});

		// handle content request
		client.onRequest(VSCodeContentRequest.type, (uriPath: string) => {
			let uri = Uri.parse(uriPath);
			return workspace.openTextDocument(uri).then(doc => {
				return doc.getText();
			}, error => {
				return Promise.reject(error);
			});
		});

		let handleContentChange = (uri: Uri) => {
			if (uri.scheme === 'vscode' && uri.authority === 'schemas') {
				client.sendNotification(SchemaContentChangeNotification.type, uri.toString());
			}
		};
		toDispose.push(workspace.onDidChangeTextDocument(e => handleContentChange(e.document.uri)));
		toDispose.push(workspace.onDidCloseTextDocument(d => handleContentChange(d.uri)));

		client.sendNotification(SchemaAssociationNotification.type, getSchemaAssociation(context));
	});
export function activate(context: ExtensionContext): any {
    
    context.subscriptions.push(languages.registerCompletionItemProvider('todo', new TodoCompletionItemProvider(), '@'));
    context.subscriptions.push(languages.registerCodeActionsProvider('todo', new TodoCodeActionProvider()));

    languages.setLanguageConfiguration('todo', {
        wordPattern: /(-?\d*\.\d\w*)|([^\-\`\~\!\#\%\^\&\*\(\)\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g,
        indentationRules: {
            increaseIndentPattern: /^\s*\w+.+:\s*$/,
            decreaseIndentPattern: /^\uffff$/ //Does not match any
        }
    });

    let todoCommands= new TodoCommands();
    context.subscriptions.push(todoCommands.registerNewTaskCommand());
    context.subscriptions.push(todoCommands.registerCompleteTaskCommand());
    context.subscriptions.push(todoCommands.registerCancelTaskCommand());
    context.subscriptions.push(workspace.onDidChangeTextDocument((e: TextDocumentChangeEvent) => {
        _decorateEditor(true);
    }));

    window.onDidChangeActiveTextEditor(editor => {
		_decorateEditor();
	}, null, context.subscriptions);

    _decorateEditor();
}
Example #3
0
export function activateTagClosing(tagProvider: (document: TextDocument, position: Position) => Thenable<string>, supportedLanguages: { [id: string]: boolean }, configName: string): Disposable {

	let disposables: Disposable[] = [];
	workspace.onDidChangeTextDocument(event => onDidChangeTextDocument(event.document, event.contentChanges), null, disposables);

	let isEnabled = false;
	updateEnabledState();
	window.onDidChangeActiveTextEditor(updateEnabledState, null, disposables);

	let timeout: NodeJS.Timer = void 0;

	function updateEnabledState() {
		isEnabled = false;
		let editor = window.activeTextEditor;
		if (!editor) {
			return;
		}
		let document = editor.document;
		if (!supportedLanguages[document.languageId]) {
			return;
		}
		if (!workspace.getConfiguration(void 0, document.uri).get<boolean>(configName)) {
			return;
		}
		isEnabled = true;
	}

	function onDidChangeTextDocument(document: TextDocument, changes: TextDocumentContentChangeEvent[]) {
		if (!isEnabled) {
			return;
		}
		let activeDocument = window.activeTextEditor && window.activeTextEditor.document;
		if (document !== activeDocument || changes.length === 0) {
			return;
		}
		if (typeof timeout !== 'undefined') {
			clearTimeout(timeout);
		}
		let lastChange = changes[changes.length - 1];
		let lastCharacter = lastChange.text[lastChange.text.length - 1];
		if (lastChange.rangeLength > 0 || lastCharacter !== '>' && lastCharacter !== '/') {
			return;
		}
		let rangeStart = lastChange.range.start;
		let version = document.version;
		timeout = setTimeout(() => {
			let position = new Position(rangeStart.line, rangeStart.character + lastChange.text.length);
			tagProvider(document, position).then(text => {
				if (text && isEnabled) {
					let activeDocument = window.activeTextEditor && window.activeTextEditor.document;
					if (document === activeDocument && activeDocument.version === version) {
						window.activeTextEditor.insertSnippet(new SnippetString(text), position);
					}
				}
			});
		}, 100);
	}
	return Disposable.from(...disposables);
}
Example #4
0
	client.onReady().then(() => {
		client.onTelemetry(e => {
			if (telemetryReporter) {
				telemetryReporter.sendTelemetryEvent(e.key, e.data);
			}
		});

		// handle content request
		client.onRequest(VSCodeContentRequest.type, (uriPath: string) => {
			let uri = Uri.parse(uriPath);
			return workspace.openTextDocument(uri).then(doc => {
				return doc.getText();
			}, error => {
				return Promise.reject(error);
			});
		});

		let handleContentChange = (uri: Uri) => {
			if (uri.scheme === 'vscode' && uri.authority === 'schemas') {
				client.sendNotification(SchemaContentChangeNotification.type, uri.toString());
			}
		};
		toDispose.push(workspace.onDidChangeTextDocument(e => handleContentChange(e.document.uri)));
		toDispose.push(workspace.onDidCloseTextDocument(d => handleContentChange(d.uri)));

		client.sendNotification(SchemaAssociationNotification.type, getSchemaAssociation(context));

		// register color provider
		toDispose.push(languages.registerColorProvider(documentSelector, {
			provideDocumentColors(document: TextDocument): Thenable<ColorInformation[]> {
				let params: DocumentColorParams = {
					textDocument: client.code2ProtocolConverter.asTextDocumentIdentifier(document)
				};
				return client.sendRequest(DocumentColorRequest.type, params).then(symbols => {
					return symbols.map(symbol => {
						let range = client.protocol2CodeConverter.asRange(symbol.range);
						let color = new Color(symbol.color.red, symbol.color.green, symbol.color.blue, symbol.color.alpha);
						return new ColorInformation(range, color);
					});
				});
			},
			provideColorPresentations(color: Color, context): Thenable<ColorPresentation[]> {
				let params: ColorPresentationParams = {
					textDocument: client.code2ProtocolConverter.asTextDocumentIdentifier(context.document),
					color: color,
					range: client.code2ProtocolConverter.asRange(context.range)
				};
				return client.sendRequest(ColorPresentationRequest.type, params).then(presentations => {
					return presentations.map(p => {
						let presentation = new ColorPresentation(p.label);
						presentation.textEdit = p.textEdit && client.protocol2CodeConverter.asTextEdit(p.textEdit);
						presentation.additionalTextEdits = p.additionalTextEdits && client.protocol2CodeConverter.asTextEdits(p.additionalTextEdits);
						return presentation;
					});
				});
			}
		}));
	});
Example #5
0
export function activate(context: vscode.ExtensionContext) {
    diagnosticCollection = vscode.languages.createDiagnosticCollection('lua');
    context.subscriptions.push(diagnosticCollection);

    vscode.workspace.onDidSaveTextDocument(document => lintDocument(document, true));
    vscode.workspace.onDidChangeTextDocument(event => lintDocument(event.document));
    vscode.workspace.onDidOpenTextDocument(document => lintDocument(document));
    vscode.window.onDidChangeActiveTextEditor((editor: vscode.TextEditor) => lintDocument(editor.document));
}
			return new Promise<void>((resolve, reject) => {
				let subscription = workspace.onDidChangeTextDocument(d => {
					if (d.document.uri.toString() === virtualURIString) {
						subscription.dispose();
						resolve();
					}
				});
				embeddedContentChanged.fire(virtualURI);
			});
Example #7
0
	return new Promise<vscode.TextDocument>(resolve => {
		const sub = vscode.workspace.onDidChangeTextDocument(e => {
			if (e.document !== doc) {
				return;
			}
			sub.dispose();
			resolve(e.document);
		});
	});
    constructor(private log: Logger) {
        this.settings = Settings.load();

        if (this.settings.helpCompletion !== Settings.HelpCompletion.Disabled) {
            this.helpCompletionProvider = new HelpCompletionProvider();
            const subscriptions = [];
            workspace.onDidChangeTextDocument(this.onEvent, this, subscriptions);
            this.disposable = Disposable.from(...subscriptions);
        }
    }
Example #9
0
export function activate() {
	vscode.workspace.onDidChangeTextDocument((event: TextDocumentChangeEvent) => {
		if (!checkUiFlow(event.document)) return;
		validateTextDocument(event.document);
	});
	vscode.workspace.onDidOpenTextDocument(document => {
		if (!checkUiFlow(document)) return;
		validateTextDocument(document);
	});
}
export function activate(context: vscode.ExtensionContext) {
    vscode.workspace.onDidChangeTextDocument(event => {
        insertAutoCloseTag(event);
    });

    let closeTag = vscode.commands.registerCommand('auto-close-tag.closeTag', () => {
        insertCloseTag();
    });

    context.subscriptions.push(closeTag);
}
export function activate(context: vscode.ExtensionContext) {
  const conf = vscode.workspace.getConfiguration('emptyIndent');

  const removeIndent = conf.get<boolean>('removeIndent');
  const highlightIndent = conf.get<boolean>('highlightIndent');
  const highlightColor = conf.get<string>('highlightColor');
  const exclude = conf.get<Array<string>>('exclude');

  let activeEditor = vscode.window.activeTextEditor;

  if (removeIndent) {
    vscode.workspace.onDidSaveTextDocument(event => {
      if (checkExclude(event.fileName, exclude)) {
        return;
      }

      vscode.commands.executeCommand('editor.action.trimTrailingWhitespace');
      vscode.window.activeTextEditor.document.save();
    });
  }

  if (highlightIndent) {

     let decoration = vscode.window.createTextEditorDecorationType({
       backgroundColor: highlightColor
     });

     vscode.window.onDidChangeActiveTextEditor(editor => {
      activeEditor = editor;
      if (editor && !checkExclude(activeEditor.document.fileName, exclude)) {
        updateDecorations(editor, decoration);
      }
    }, null, context.subscriptions);

    vscode.workspace.onDidChangeTextDocument(event => {
      if (
        activeEditor &&
        event.document === activeEditor.document &&
        !checkExclude(activeEditor.document.fileName, exclude)
      ) {
        updateDecorations(activeEditor, decoration);
      }
    }, null, context.subscriptions);

    vscode.window.onDidChangeTextEditorSelection(event => {
        const line = event.selections.length === 1 ? event.selections[0].active : null;
        if (activeEditor && !checkExclude(activeEditor.document.fileName, exclude)) {
          updateDecorations(activeEditor, decoration, line);
        }
    }, null, context.subscriptions);
  }

}
Example #12
0
			return new Promise((resolve, reject) => {

				workspace.onDidChangeTextDocument(event => {
					assert.ok(event.document === doc);
					assert.equal(event.document.getText(), 'call1');
					resolve();
				});

				listeners.forEach(l => l(doc.uri));

				registration.dispose();
			});
Example #13
0
function setupDecorators(context: ExtensionContext) {
	let timeout: NodeJS.Timer | undefined = undefined;
	const path = vscode.extensions.getExtension('peterzeller.wurst').extensionPath;
	const compiletimeDecorator = vscode.window.createTextEditorDecorationType({
		gutterIconPath: `${path}/images/gears.svg`,
    	gutterIconSize: 'contain',
	});

	let activeEditor = vscode.window.activeTextEditor;

	function updateDecorations() {
		if (!activeEditor) {
			return;
		}
    	timeout = undefined;
		const regEx = /@compiletime\s+(\s*(static|public|private)\s)*function.+/g;
		const text = activeEditor.document.getText();
		const compiletime: vscode.DecorationOptions[] = [];
		let match;
		while (match = regEx.exec(text)) {
			const startPos = activeEditor.document.positionAt(match.index);
			const endPos = activeEditor.document.positionAt(match.index + match[0].length);
			const decoration = { range: new vscode.Range(startPos, endPos), hoverMessage: 'This function will be executed at compiletime.' };
			compiletime.push(decoration);
		}
		activeEditor.setDecorations(compiletimeDecorator, compiletime);
	}

	function triggerUpdateDecorations() {
		if (timeout) {
			clearTimeout(timeout);
		}
		timeout = setTimeout(updateDecorations, 500);
	}

	if (activeEditor) {
		triggerUpdateDecorations();
	}

	vscode.window.onDidChangeActiveTextEditor(editor => {
		activeEditor = editor;
		if (editor) {
			triggerUpdateDecorations();
		}
	}, null, context.subscriptions);

	vscode.workspace.onDidChangeTextDocument(event => {
		if (activeEditor && event.document === activeEditor.document) {
			triggerUpdateDecorations();
		}
	}, null, context.subscriptions);
}
    run() {
        vscode.window.onDidChangeActiveTextEditor(event => {
            this.getCurrentWordForNewActiveTextEditor(event);
        })

        vscode.window.onDidChangeTextEditorSelection(event => {
            this.getCurrentWord(event);
        })

        vscode.workspace.onDidChangeTextDocument(event => {
            this.updatePairedTag(event);
        });
    }
Example #15
0
export function activate(context: vscode.ExtensionContext) {
  // To make us VS Code agnostic outside of this file
  const pluginSettings = getExtensionSettings()
  const jestPath = pathToJest(pluginSettings)
  const configPath = pathToConfig(pluginSettings)
  const currentJestVersion = 20
  const workspace = new ProjectWorkspace(pluginSettings.rootPath, jestPath, configPath, currentJestVersion)

  // Create our own console
  const channel = vscode.window.createOutputChannel('Jest')

  // We need a singleton to represent the extension
  extensionInstance = new JestExt(workspace, channel, pluginSettings)

  const languages = [
    { language: 'javascript' },
    { language: 'javascriptreact' },
    { language: 'typescript' },
    { language: 'typescriptreact' },
  ]
  context.subscriptions.push(
    registerStatusBar(channel),
    vscode.commands.registerTextEditorCommand(`${extensionName}.start`, () => {
      vscode.window.showInformationMessage('Started Jest, press escape to hide this message.')
      extensionInstance.startProcess()
    }),
    vscode.commands.registerTextEditorCommand(`${extensionName}.stop`, () => extensionInstance.stopProcess()),
    vscode.commands.registerTextEditorCommand(`${extensionName}.show-channel`, () => {
      channel.show()
    }),
    ...registerSnapshotCodeLens(pluginSettings.enableSnapshotPreviews),
    ...registerSnapshotPreview(),
    ...registerCoverageCodeLens(extensionInstance),
    registerToggleCoverageOverlay(pluginSettings.showCoverageOnLoad),
    vscode.commands.registerCommand(`${extensionName}.run-test`, extensionInstance.runTest),
    vscode.languages.registerCodeLensProvider(languages, extensionInstance.debugCodeLensProvider),
    vscode.workspace.onDidChangeConfiguration(e => {
      if (e.affectsConfiguration('jest')) {
        const updatedSettings = getExtensionSettings()
        extensionInstance.triggerUpdateSettings(updatedSettings)
      }
    }),

    vscode.workspace.onDidCloseTextDocument(document => {
      extensionInstance.onDidCloseTextDocument(document)
    }),

    vscode.window.onDidChangeActiveTextEditor(extensionInstance.onDidChangeActiveTextEditor, extensionInstance),
    vscode.workspace.onDidChangeTextDocument(extensionInstance.onDidChangeTextDocument, extensionInstance)
  )
}
export function activate(context: ExtensionContext) {
  const abapFS = new FsProvider()
  const sub = context.subscriptions
  // register the filesystem type
  sub.push(
    workspace.registerFileSystemProvider(ADTSCHEME, abapFS, {
      isCaseSensitive: true
    })
  )

  // change document listener, for locking (and possibly validation in future)
  sub.push(workspace.onDidChangeTextDocument(documentChangedListener))
  // opened document listener, for main program
  sub.push(workspace.onDidOpenTextDocument(documentOpenListener))
  // closed document listener, for locking
  sub.push(workspace.onDidCloseTextDocument(documentClosedListener))
  // Editor changed listener, updates context and icons
  sub.push(window.onDidChangeActiveTextEditor(activeTextEditorChangedListener))

  // connect command
  sub.push(commands.registerCommand("abapfs.connect", connectAdtServer))

  // activate command
  sub.push(commands.registerCommand("abapfs.activate", activateCurrent))

  // search command
  sub.push(commands.registerCommand("abapfs.search", searchAdtObject))

  // create command
  sub.push(commands.registerCommand("abapfs.create", createAdtObject))

  // execute Abap command
  sub.push(commands.registerCommand("abapfs.execute", executeAbap))

  // add favourite
  sub.push(commands.registerCommand("abapfs.addfavourite", addFavourite))

  // add favourite
  sub.push(commands.registerCommand("abapfs.deletefavourite", deleteFavourite))

  const fav = FavouritesProvider.get()
  fav.storagePath = context.globalStoragePath
  sub.push(window.registerTreeDataProvider("abapfs.favorites", fav))

  startLanguageClient(context)

  commands.executeCommand("setContext", "abapfs:extensionActive", true)
  restoreLocks()

  log(`Activated,pid=${process.pid}`)
}
Example #17
0
export function activate(context: ExtensionContext) {
    
    let version = "5.20161.151";
    let previewUri: Uri;
    let csvProvider = new csv.CsvDocumentContentProvider(version);
    let csvSubscription = workspace.registerTextDocumentContentProvider('csv-preview', csvProvider);
    let excelProvider = new excel.ExcelDocumentContentProvider(version);
    let excelSubscription = workspace.registerTextDocumentContentProvider('excel-preview', excelProvider);
    
    workspace.onDidChangeTextDocument((e: TextDocumentChangeEvent) => {
        if (e.document === window.activeTextEditor.document) {
            csvProvider.update(previewUri);
        }
    });
    
    let csvCommand = commands.registerCommand('csv.preview', () => {
        let file = window.activeTextEditor.document.fileName;
        if (file.startsWith("/")) {
            file = file.substring(1);
        }
        previewUri = Uri.parse(`csv-preview://preview/${file}`);
        return commands.executeCommand('vscode.previewHtml', previewUri, ViewColumn.One).then((success) => {
        }, (reason) => {
            window.showErrorMessage(reason);
        });
    });
    
    let excelCommand = commands.registerCommand('excel.preview', () => {
        var files = workspace.findFiles('**/*.xls*', '**/node_modules/**').then((value: Uri[]) => {
            var path = workspace.rootPath;
            var uris = value.map(function (u) {
                return u.path.slice(path.length + 1);
            });
            if (!path.startsWith("/")) {
                path = "/" + path;
            }
            window.showQuickPick(uris).then(sel => {
                excelProvider.setPath(sel);
                previewUri = Uri.parse(`excel-preview://preview${path}/${sel}`);
                return commands.executeCommand('vscode.previewHtml', previewUri, ViewColumn.One).then((success) => {
                }, (reason) => {
                    window.showErrorMessage(reason);
                });                
            });
        });
    });
    
    context.subscriptions.push(csvCommand, csvSubscription);
    context.subscriptions.push(excelCommand, excelSubscription);
}
Example #18
0
export function activate(context: vscode.ExtensionContext) {

    // Use the console to output diagnostic information (console.log) and errors (console.error)
    // This line of code will only be executed once when your extension is activated
    console.log('Congratulations, your extension "lua-luachecker" is now active!');

    diagnosticCollection = vscode.languages.createDiagnosticCollection('lua');
context.subscriptions.push(diagnosticCollection);

    vscode.workspace.onDidSaveTextDocument(document => lintDocument(document, true));
    vscode.workspace.onDidChangeTextDocument(event => lintDocument(event.document));
    vscode.workspace.onDidOpenTextDocument(document => lintDocument(document));
    vscode.window.onDidChangeActiveTextEditor((editor: vscode.TextEditor) => lintDocument(editor.document));
}
    activate() {
        let subscriptions: vscode.Disposable[] = [];
        vscode.window.onDidChangeTextEditorSelection(this.onTextEditorSelectionChanged, this, subscriptions);
        vscode.window.onDidChangeActiveTextEditor(this.onActiveTextEditorChanged, this, subscriptions);
        vscode.workspace.onDidSaveTextDocument(this.onTextDocumentSaved, this, subscriptions);
        vscode.workspace.onDidChangeTextDocument(this.onTextDocumentChanged, this, subscriptions);

        this._disposable = vscode.Disposable.from(...subscriptions);

        var activeEditor = vscode.window.activeTextEditor;
        if (activeEditor != null && activeEditor.document != null) {
            this._activeDocumentPath = vscode.window.activeTextEditor.document.fileName;            
        }
    }
Example #20
0
export function activate(context) {

	//keybindings.json command-suggestions
	context.subscriptions.push(registerKeybindingsCompletions());

	// launch.json decorations
	context.subscriptions.push(vscode.window.onDidChangeActiveTextEditor(editor => updateLaunchJsonDecorations(editor), null, context.subscriptions));
	context.subscriptions.push(vscode.workspace.onDidChangeTextDocument(event => {
		if (vscode.window.activeTextEditor && event.document === vscode.window.activeTextEditor.document) {
			updateLaunchJsonDecorations(vscode.window.activeTextEditor);
		}
	}, null, context.subscriptions));
	updateLaunchJsonDecorations(vscode.window.activeTextEditor);
}
    private registerEventListeners(): void {
        let disposables: vscode.Disposable[] = []
        if (this.settings.liveMatching) {
            disposables.push(
                vscode.window.onDidChangeActiveTextEditor((editor: vscode.TextEditor | undefined) => {
                    if (editor !== undefined) {
                        this.logger.log(`onDidChangeActiveTextEditor event called - ${editor.document.fileName}`);
                        this.trailingSpaces.highlight(editor);
                    }
                }),
                vscode.workspace.onDidChangeTextDocument((event: vscode.TextDocumentChangeEvent) => {
                    if (vscode.window.activeTextEditor !== undefined && vscode.window.activeTextEditor.document == event.document) {
                        this.logger.log(`onDidChangeTextDocument event called - ${event.document.fileName}`);
                        this.trailingSpaces.highlight(vscode.window.activeTextEditor);
                    }
                }),
                vscode.workspace.onDidOpenTextDocument((document: vscode.TextDocument) => {
                    if (vscode.window.activeTextEditor !== undefined && vscode.window.activeTextEditor.document == document) {
                        this.logger.log(`onDidOpenTextDocument event called - ${document.fileName}`);
                        this.trailingSpaces.highlight(vscode.window.activeTextEditor);
                    }
                })
            );

            if (!this.settings.highlightCurrentLine) {
                disposables.push(
                    vscode.window.onDidChangeTextEditorSelection((event: vscode.TextEditorSelectionChangeEvent) => {
                        let editor: vscode.TextEditor = event.textEditor;
                        this.logger.log(`onDidChangeTextEditorSelection event called - ${editor.document.fileName}`);
                        this.trailingSpaces.highlight(editor);
                    })
                );
            }
        }

        if (this.settings.trimOnSave) {
            disposables.push(
                vscode.workspace.onWillSaveTextDocument((event: vscode.TextDocumentWillSaveEvent) => {
                    this.logger.log(`onWillSaveTextDocument event called - ${event.document.fileName}`);
                    vscode.window.visibleTextEditors.forEach((editor: vscode.TextEditor) => {
                        if (event.document.uri === editor.document.uri) {
                            event.waitUntil(Promise.resolve(this.trailingSpaces.getEditsForDeletingTralingSpaces(editor.document)));
                        }
                    });
                })
            );
        }
        this.listenerDisposables = disposables;
    }
Example #22
0
			return new Promise<string>(async resolve => {
				const doc = await createDoc(options.contents);
				workspace.onDidChangeTextDocument(doc.save);
				workspace.onDidSaveTextDocument(savedDoc => {
					assert.strictEqual(savedDoc.isDirty, false, 'dirty saved doc');
					resolve(savedDoc.getText());
				});
				const edit = new WorkspaceEdit();
				edit.insert(doc.uri, new Position(0, 0), text);
				assert.strictEqual(
					await workspace.applyEdit(edit),
					true,
					'editor fails to apply edit'
				);
			});
Example #23
0
    constructor()
    {
        let subscriptions: vscode.Disposable[] = [];
        vscode.workspace.onDidChangeTextDocument((e) => this.onChangeTextHandler(e.document), null, subscriptions);
        vscode.window.onDidChangeActiveTextEditor(editor => { this.onChangeEditorHandler(editor) }, null, subscriptions);
        this.disposable = vscode.Disposable.from(...subscriptions);

        this.todoCommentDecoration = vscode.window.createTextEditorDecorationType({
            overviewRulerLane: vscode.OverviewRulerLane.Right,
            color: "rgba(91, 199, 235, 1)",
            overviewRulerColor: 'rgba(144, 195, 212, 0.7)' // Light Blue
        });

        this.styleTodoComments();
    }
    test("behaviour of text-transformer framework (async)", (done: MochaDone) => {
        vscode.workspace.onDidChangeTextDocument(singleFire((change: vscode.TextDocumentChangeEvent) => { //We need singleFire here, otherwise this handler gets procesed when editor content changed during second testcase
            const text = vscode.window.activeTextEditor.document.getText();

            try { //Usually one wouldn"t need this construct - but it seems like the "thenables" catch the error before getting up higher in the stack
                assert.equal(text, "HAllo, HIER bin ich!\n");
            }
            catch (err) {
                return done(err);
            }

            done();
        }));

        vscode.commands.executeCommand("Test-Transformer-Async");
    });
Example #25
0
export function activate(context: vscode.ExtensionContext) {
    const vim = new Vim();

    let disposable = vscode.commands.registerCommand("type", args => {
        vim.key(args.text);
    });
    context.subscriptions.push(disposable);

    disposable = vscode.commands.registerCommand("extension.vimEscape", () => {
        vim.key("<esc>");
    });
    context.subscriptions.push(disposable);

    disposable = vscode.commands.registerCommand("extension.vimLeft", () => {
        vim.key("<left>");
    });
    context.subscriptions.push(disposable);

    disposable = vscode.commands.registerCommand("extension.vimRight", () => {
        vim.key("<right>");
    });
    context.subscriptions.push(disposable);

    disposable = vscode.commands.registerCommand("extension.vimUp", () => {
        vim.key("<up>");
    });
    context.subscriptions.push(disposable);

    disposable = vscode.commands.registerCommand("extension.vimDown", () => {
        vim.key("<down>");
    });
    context.subscriptions.push(disposable);

    vscode.window.onDidChangeTextEditorSelection(e => {
        vim.updateSelection(e.selections);
    });

    vscode.workspace.onDidChangeTextDocument(e => {
        vim.documentChanged(e);
    });

    vscode.window.onDidChangeActiveTextEditor(e => {
        vim.updateUI();
    });

    vim.updateUI();
}
export function activate(disposables: Disposable[]) {
    console.log("Spell and Grammar checker active...");
    
    // TODO [p2] Currently the only way to refresh is to reload window add a wacher
    settings = readSettings();

    commands.registerCommand('Spell.suggestFix', suggestFix);
    commands.registerCommand('Spell.changeLanguage', changeLanguage);

    // Link into the two critical lifecycle events
    workspace.onDidChangeTextDocument(event => {
        CreateDiagnostics(event.document)
    }, undefined, disposables);

    workspace.onDidOpenTextDocument(event => {
        CreateDiagnostics(event)
    }, undefined, disposables);
}
function forwardDocumentChanges(server: OmnisharpServer): Disposable {

	return workspace.onDidChangeTextDocument(event => {

		let {document} = event;
		if (document.isUntitled || document.languageId !== 'csharp') {
			return;
		}

		if (!server.isRunning()) {
			return;
		}

		serverUtils.updateBuffer(server, {Buffer: document.getText(), Filename: document.fileName}).catch(err => {
			console.error(err);
			return err;
		});
	});
}
Example #28
0
    constructor()
    {
        this.delayers = Object.create(null);

        let subscriptions: vscode.Disposable[] = [];
        vscode.workspace.onDidChangeTextDocument((e) => this.onChangeTextHandler(e.document), null, subscriptions);
        vscode.workspace.onDidCloseTextDocument((textDocument)=> { delete this.delayers[textDocument.uri.toString()]; }, null, subscriptions);
        vscode.window.onDidChangeActiveTextEditor(editor => { this.onChangeEditorHandler(editor) }, null, subscriptions);
        this.disposable = vscode.Disposable.from(...subscriptions);

        this.todoCommentDecoration = vscode.window.createTextEditorDecorationType({
            overviewRulerLane: vscode.OverviewRulerLane.Right,
            color: "rgba(91, 199, 235, 1)",
            overviewRulerColor: 'rgba(144, 195, 212, 0.7)', // Light Blue
            isWholeLine: false,
            backgroundColor: 'rgba(91, 199, 235, 0.1)'
        });

        this.styleTodoComments();
    }
Example #29
0
		return createRandomFile().then(file => {
			let disposables = [];

			let onDidOpenTextDocument = false;
			disposables.push(workspace.onDidOpenTextDocument(e => {
				assert.ok(pathEquals(e.uri.fsPath, file.fsPath));
				onDidOpenTextDocument = true;
			}));

			let onDidChangeTextDocument = false;
			disposables.push(workspace.onDidChangeTextDocument(e => {
				assert.ok(pathEquals(e.document.uri.fsPath, file.fsPath));
				onDidChangeTextDocument = true;
			}));

			let onDidSaveTextDocument = false;
			disposables.push(workspace.onDidSaveTextDocument(e => {
				assert.ok(pathEquals(e.uri.fsPath, file.fsPath));
				onDidSaveTextDocument = true;
			}));

			return workspace.openTextDocument(file).then(doc => {
				return window.showTextDocument(doc).then((editor) => {
					return editor.edit((builder) => {
						builder.insert(new Position(0, 0), 'Hello World');
					}).then(applied => {
						return doc.save().then(saved => {
							assert.ok(onDidOpenTextDocument);
							assert.ok(onDidChangeTextDocument);
							assert.ok(onDidSaveTextDocument);

							while (disposables.length) {
								disposables.pop().dispose();
							}

							return deleteFile(file);
						});
					});
				});
			});
		});
Example #30
0
export function activate(context: vscode.ExtensionContext) 
{
    console.log('uri-test is now active!');
    
    context.subscriptions.push(languages.registerHoverProvider(supportedLanguages, new CustomHoverProvider()));
    
    context.subscriptions.push(commands.registerCommand('extension.createDemoFiles', () => 
    {
        var fs = require('fs');
        
        try
        {
            var path1 = workspace.rootPath + "\\test.txt";
            var path2 = workspace.rootPath + "\\plain.txt";
            
            fs.writeFileSync(path1, 'This is a plain text file. Mouse-over the word "plain" to bring up a clickable link.');
            fs.writeFileSync(path2, 'Did you open me via the mouse-over popup? Good. Now edit me.');
            
            var openDocument = workspace.openTextDocument(path1);
            openDocument.then((document:TextDocument) => 
            {
                window.showTextDocument(document); 
            });
        }
        catch (ex)
        {
            window.showErrorMessage(`Unable to create demo files. Please open a workspace folder first. \n${ex.toString()}`);
        }
    }));
    
    workspace.onDidChangeTextDocument((e:TextDocumentChangeEvent) => 
    {
        var document = e.document;
        var fileName = Path.GetFileName(document.fileName);
        
        if (fileName == "plain.txt")
        {
            window.showInformationMessage(`Did a ghost file, starting with '\\\\', appear in 'WORKING FILES'?`);
        }
    });
}