Skip to content

Commit

Permalink
Work around VSC issue with formatting on save #624 (#635)
Browse files Browse the repository at this point in the history
* Basic tokenizer

* Fixed property names

* Tests, round I

* Tests, round II

* tokenizer test

* Remove temorary change

* Fix merge issue

* Merge conflict

* Merge conflict

* Completion test

* Fix last line

* Fix javascript math

* Make test await for results

* Add license headers

* Rename definitions to types

* License headers

* Fix typo in completion details (typo)

* Fix hover test

* Russian translations

* Update to better translation

* Fix typo

*  #70 How to get all parameter info when filling in a function param list

* Fix #70 How to get all parameter info when filling in a function param list

* Clean up

* Clean imports

* CR feedback

* Trim whitespace for test stability

* More tests

* Better handle no-parameters documentation

* Better handle ellipsis and Python3

* #385 Auto-Indentation doesn't work after comment

* #141 Auto indentation broken when return keyword involved

* Undo changes

* Round I

* Round 2

* Round 3

* Round 4

* Round 5

* no message

* Round 6

* Round 7

* Clean up targets and messages

* Settings propagation

* Tests

* Test warning

* Fix installer tests

* Tests

* Test fixes

* Fix terminal service and tests async/await

* Fix mock setup

* Test fix

* Test async/await fix

* Test fix + activate tslint on awaits

* Use command manager

* Work around updateSettings

* Multiroot fixes, partial

* More workarounds

* Multiroot tests

* Fix installer test

* Test fixes

* Disable prospector

* Enable dispose in all cases

* Fix event firing

* Min pylint options

* Min checkers & pylintrc discovery

* Fix Windows path in tests for Travis

* Fix Mac test

* Test fix

* Work around VSC issue with formatting on save #624

* Workaround test

* Unused

* Old file

* Use version instead of content

* Update tests
  • Loading branch information
Mikhail Arkhipov authored Jan 29, 2018
1 parent f869369 commit 94cd778
Show file tree
Hide file tree
Showing 15 changed files with 409 additions and 210 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@
"onCommand:python.startREPL",
"onCommand:python.goToPythonObject",
"onCommand:python.setLinter",
"onCommand:python.enableLinting",
"onCommand:python.createTerminal"
"onCommand:python.enableLinting",
"onCommand:python.createTerminal"
],
"main": "./out/client/extension",
"contributes": {
Expand Down
6 changes: 4 additions & 2 deletions src/client/common/application/documentManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// tslint:disable:no-any

import { injectable } from 'inversify';
import { Event, TextDocument, TextDocumentShowOptions, TextEditor, TextEditorOptionsChangeEvent, TextEditorSelectionChangeEvent, TextEditorViewColumnChangeEvent, Uri, ViewColumn, window } from 'vscode';
import { Event, TextDocument, TextDocumentShowOptions, TextEditor, TextEditorOptionsChangeEvent, TextEditorSelectionChangeEvent, TextEditorViewColumnChangeEvent, Uri, ViewColumn, window, workspace } from 'vscode';
import { IDocumentManager } from './types';

@injectable()
Expand All @@ -30,10 +30,12 @@ export class DocumentManager implements IDocumentManager {
public get onDidChangeTextEditorViewColumn(): Event<TextEditorViewColumnChangeEvent> {
return window.onDidChangeTextEditorViewColumn;
}
public get onDidSaveTextDocument(): Event<TextDocument> {
return workspace.onDidSaveTextDocument;
}
public showTextDocument(document: TextDocument, column?: ViewColumn, preserveFocus?: boolean): Thenable<TextEditor>;
public showTextDocument(document: TextDocument | Uri, options?: TextDocumentShowOptions): Thenable<TextEditor>;
public showTextDocument(uri: any, options?: any, preserveFocus?: any): Thenable<TextEditor> {
return window.showTextDocument(uri, options, preserveFocus);
}

}
5 changes: 5 additions & 0 deletions src/client/common/application/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,11 @@ export interface IDocumentManager {
*/
readonly onDidChangeTextEditorViewColumn: Event<TextEditorViewColumnChangeEvent>;

/**
* An event that is emitted when a [text document](#TextDocument) is saved to disk.
*/
readonly onDidSaveTextDocument: Event<TextDocument>;

/**
* Show the given document in a text editor. A [column](#ViewColumn) can be provided
* to control where the editor is being shown. Might change the [active editor](#window.activeTextEditor).
Expand Down
36 changes: 18 additions & 18 deletions src/client/common/application/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,36 @@
// Licensed under the MIT License.

import { injectable } from 'inversify';
import { CancellationToken, Event, FileSystemWatcher, GlobPattern, Uri, workspace, WorkspaceConfiguration, WorkspaceFolder, WorkspaceFoldersChangeEvent } from 'vscode';
import * as vscode from 'vscode';
import { IWorkspaceService } from './types';

@injectable()
export class WorkspaceService implements IWorkspaceService {
public get onDidChangeConfiguration(): Event<void> {
return workspace.onDidChangeConfiguration;
public get onDidChangeConfiguration(): vscode.Event<void> {
return vscode.workspace.onDidChangeConfiguration;
}
public get rootPath(): string | undefined {
return workspace.rootPath;
return vscode.workspace.rootPath;
}
public get workspaceFolders(): WorkspaceFolder[] | undefined {
return workspace.workspaceFolders;
public get workspaceFolders(): vscode.WorkspaceFolder[] | undefined {
return vscode.workspace.workspaceFolders;
}
public get onDidChangeWorkspaceFolders(): Event<WorkspaceFoldersChangeEvent> {
return workspace.onDidChangeWorkspaceFolders;
public get onDidChangeWorkspaceFolders(): vscode.Event<vscode.WorkspaceFoldersChangeEvent> {
return vscode.workspace.onDidChangeWorkspaceFolders;
}
public getConfiguration(section?: string, resource?: Uri): WorkspaceConfiguration {
return workspace.getConfiguration(section, resource);
public getConfiguration(section?: string, resource?: vscode.Uri): vscode.WorkspaceConfiguration {
return vscode.workspace.getConfiguration(section, resource);
}
public getWorkspaceFolder(uri: Uri): WorkspaceFolder | undefined {
return workspace.getWorkspaceFolder(uri);
public getWorkspaceFolder(uri: vscode.Uri): vscode.WorkspaceFolder | undefined {
return vscode.workspace.getWorkspaceFolder(uri);
}
public asRelativePath(pathOrUri: string | Uri, includeWorkspaceFolder?: boolean): string {
return workspace.asRelativePath(pathOrUri, includeWorkspaceFolder);
public asRelativePath(pathOrUri: string | vscode.Uri, includeWorkspaceFolder?: boolean): string {
return vscode.workspace.asRelativePath(pathOrUri, includeWorkspaceFolder);
}
public createFileSystemWatcher(globPattern: GlobPattern, ignoreCreateEvents?: boolean, ignoreChangeEvents?: boolean, ignoreDeleteEvents?: boolean): FileSystemWatcher {
return workspace.createFileSystemWatcher(globPattern, ignoreChangeEvents, ignoreChangeEvents, ignoreDeleteEvents);
public createFileSystemWatcher(globPattern: vscode.GlobPattern, ignoreCreateEvents?: boolean, ignoreChangeEvents?: boolean, ignoreDeleteEvents?: boolean): vscode.FileSystemWatcher {
return vscode.workspace.createFileSystemWatcher(globPattern, ignoreChangeEvents, ignoreChangeEvents, ignoreDeleteEvents);
}
public findFiles(include: GlobPattern, exclude?: GlobPattern, maxResults?: number, token?: CancellationToken): Thenable<Uri[]> {
return workspace.findFiles(include, exclude, maxResults, token);
public findFiles(include: vscode.GlobPattern, exclude?: vscode.GlobPattern, maxResults?: number, token?: vscode.CancellationToken): Thenable<vscode.Uri[]> {
return vscode.workspace.findFiles(include, exclude, maxResults, token);
}
}
Loading

0 comments on commit 94cd778

Please sign in to comment.