Skip to content

Commit 94cd778

Browse files
author
Mikhail Arkhipov
authored
Work around VSC issue with formatting on save #624 (#635)
* 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
1 parent f869369 commit 94cd778

15 files changed

+409
-210
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@
7878
"onCommand:python.startREPL",
7979
"onCommand:python.goToPythonObject",
8080
"onCommand:python.setLinter",
81-
"onCommand:python.enableLinting",
82-
"onCommand:python.createTerminal"
81+
"onCommand:python.enableLinting",
82+
"onCommand:python.createTerminal"
8383
],
8484
"main": "./out/client/extension",
8585
"contributes": {

src/client/common/application/documentManager.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// tslint:disable:no-any
55

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

1010
@injectable()
@@ -30,10 +30,12 @@ export class DocumentManager implements IDocumentManager {
3030
public get onDidChangeTextEditorViewColumn(): Event<TextEditorViewColumnChangeEvent> {
3131
return window.onDidChangeTextEditorViewColumn;
3232
}
33+
public get onDidSaveTextDocument(): Event<TextDocument> {
34+
return workspace.onDidSaveTextDocument;
35+
}
3336
public showTextDocument(document: TextDocument, column?: ViewColumn, preserveFocus?: boolean): Thenable<TextEditor>;
3437
public showTextDocument(document: TextDocument | Uri, options?: TextDocumentShowOptions): Thenable<TextEditor>;
3538
public showTextDocument(uri: any, options?: any, preserveFocus?: any): Thenable<TextEditor> {
3639
return window.showTextDocument(uri, options, preserveFocus);
3740
}
38-
3941
}

src/client/common/application/types.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,11 @@ export interface IDocumentManager {
302302
*/
303303
readonly onDidChangeTextEditorViewColumn: Event<TextEditorViewColumnChangeEvent>;
304304

305+
/**
306+
* An event that is emitted when a [text document](#TextDocument) is saved to disk.
307+
*/
308+
readonly onDidSaveTextDocument: Event<TextDocument>;
309+
305310
/**
306311
* Show the given document in a text editor. A [column](#ViewColumn) can be provided
307312
* to control where the editor is being shown. Might change the [active editor](#window.activeTextEditor).

src/client/common/application/workspace.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,36 @@
22
// Licensed under the MIT License.
33

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

88
@injectable()
99
export class WorkspaceService implements IWorkspaceService {
10-
public get onDidChangeConfiguration(): Event<void> {
11-
return workspace.onDidChangeConfiguration;
10+
public get onDidChangeConfiguration(): vscode.Event<void> {
11+
return vscode.workspace.onDidChangeConfiguration;
1212
}
1313
public get rootPath(): string | undefined {
14-
return workspace.rootPath;
14+
return vscode.workspace.rootPath;
1515
}
16-
public get workspaceFolders(): WorkspaceFolder[] | undefined {
17-
return workspace.workspaceFolders;
16+
public get workspaceFolders(): vscode.WorkspaceFolder[] | undefined {
17+
return vscode.workspace.workspaceFolders;
1818
}
19-
public get onDidChangeWorkspaceFolders(): Event<WorkspaceFoldersChangeEvent> {
20-
return workspace.onDidChangeWorkspaceFolders;
19+
public get onDidChangeWorkspaceFolders(): vscode.Event<vscode.WorkspaceFoldersChangeEvent> {
20+
return vscode.workspace.onDidChangeWorkspaceFolders;
2121
}
22-
public getConfiguration(section?: string, resource?: Uri): WorkspaceConfiguration {
23-
return workspace.getConfiguration(section, resource);
22+
public getConfiguration(section?: string, resource?: vscode.Uri): vscode.WorkspaceConfiguration {
23+
return vscode.workspace.getConfiguration(section, resource);
2424
}
25-
public getWorkspaceFolder(uri: Uri): WorkspaceFolder | undefined {
26-
return workspace.getWorkspaceFolder(uri);
25+
public getWorkspaceFolder(uri: vscode.Uri): vscode.WorkspaceFolder | undefined {
26+
return vscode.workspace.getWorkspaceFolder(uri);
2727
}
28-
public asRelativePath(pathOrUri: string | Uri, includeWorkspaceFolder?: boolean): string {
29-
return workspace.asRelativePath(pathOrUri, includeWorkspaceFolder);
28+
public asRelativePath(pathOrUri: string | vscode.Uri, includeWorkspaceFolder?: boolean): string {
29+
return vscode.workspace.asRelativePath(pathOrUri, includeWorkspaceFolder);
3030
}
31-
public createFileSystemWatcher(globPattern: GlobPattern, ignoreCreateEvents?: boolean, ignoreChangeEvents?: boolean, ignoreDeleteEvents?: boolean): FileSystemWatcher {
32-
return workspace.createFileSystemWatcher(globPattern, ignoreChangeEvents, ignoreChangeEvents, ignoreDeleteEvents);
31+
public createFileSystemWatcher(globPattern: vscode.GlobPattern, ignoreCreateEvents?: boolean, ignoreChangeEvents?: boolean, ignoreDeleteEvents?: boolean): vscode.FileSystemWatcher {
32+
return vscode.workspace.createFileSystemWatcher(globPattern, ignoreChangeEvents, ignoreChangeEvents, ignoreDeleteEvents);
3333
}
34-
public findFiles(include: GlobPattern, exclude?: GlobPattern, maxResults?: number, token?: CancellationToken): Thenable<Uri[]> {
35-
return workspace.findFiles(include, exclude, maxResults, token);
34+
public findFiles(include: vscode.GlobPattern, exclude?: vscode.GlobPattern, maxResults?: number, token?: vscode.CancellationToken): Thenable<vscode.Uri[]> {
35+
return vscode.workspace.findFiles(include, exclude, maxResults, token);
3636
}
3737
}

0 commit comments

Comments
 (0)