diff --git a/.vscode/settings.json b/.vscode/settings.json index 628595a..178e57d 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -9,5 +9,9 @@ "prettier.requireConfig": true, "search.exclude": { "**/dist": true - } + }, + "editor.codeActionsOnSave": { + "source.fixAll.eslint": true + }, + "typescript.tsdk": "node_modules/typescript/lib" } diff --git a/package.json b/package.json index dbfb50e..3235da6 100644 --- a/package.json +++ b/package.json @@ -244,7 +244,7 @@ "devDependencies": { "@types/lodash-es": "4.17.3", "@types/node": "10.14.18", - "@types/vscode": "1.37.0", + "@types/vscode": "1.67.0", "@typescript-eslint/eslint-plugin": "2.4.0", "@typescript-eslint/parser": "2.4.0", "circular-dependency-plugin": "5.2.0", diff --git a/src/commands.ts b/src/commands.ts index 8f6035f..a99ef66 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -87,6 +87,23 @@ export class Commands implements Disposable { } } +function findAlreadyOpenInOtherColumn(uri: Uri) { + const uriString = uri.toString(); + const activeViewColumn = window.activeTextEditor && window.activeTextEditor.viewColumn; + const tabGroup = window.tabGroups.all.find( + (tg) => + tg.viewColumn !== activeViewColumn && + tg.tabs.some( + (tab) => { + const tabInput = tab.input; + const uri = typeof tabInput === 'object' && tabInput && (tabInput as { uri?: unknown }).uri; + return uri instanceof Uri && uri.toString() === uriString; + } + ) + ); + return tabGroup && tabGroup.viewColumn; +} + export async function openEditor( uri: Uri, options?: TextDocumentShowOptions & { openSideBySide?: boolean } @@ -98,7 +115,7 @@ export async function openEditor( preserveFocus: false, preview: true, viewColumn: openSideBySide - ? ViewColumn.Beside + ? findAlreadyOpenInOtherColumn(uri) || ViewColumn.Beside : (window.activeTextEditor && window.activeTextEditor.viewColumn) || ViewColumn.One }; diff --git a/src/rulesProvider.ts b/src/rulesProvider.ts index 2c67210..f5abe2e 100644 --- a/src/rulesProvider.ts +++ b/src/rulesProvider.ts @@ -146,7 +146,7 @@ export class RulesProvider implements Disposable { Logger.log(`RulesProvider.findFiles(${pattern}, ${maxResults})`); const files = await workspace.findFiles( - { base: rootPath, pattern: pattern }, + { base: rootPath, baseUri: Uri.file(rootPath), pattern: pattern }, this._excludes, maxResults, token diff --git a/yarn.lock b/yarn.lock index 82c2414..ee678cd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -91,10 +91,10 @@ dependencies: source-map "^0.6.1" -"@types/vscode@1.37.0": - version "1.37.0" - resolved "https://registry.yarnpkg.com/@types/vscode/-/vscode-1.37.0.tgz#fb26ffabfabcd50ba70e8b454122a91b84548080" - integrity sha512-PRfeuqYuzk3vjf+puzxltIUWC+AhEGYpFX29/37w30DQSQnpf5AgMVf7GDBAdmTbWTBou+EMFz/Ne6XCM/KxzQ== +"@types/vscode@1.67.0": + version "1.67.0" + resolved "https://registry.yarnpkg.com/@types/vscode/-/vscode-1.67.0.tgz#8eaba41d1591aa02f5d960b7dfae3b16e066f08c" + integrity sha512-GH8BDf8cw9AC9080uneJfulhSa7KHSMI2s/CyKePXoGNos9J486w2V4YKoeNUqIEkW4hKoEAWp6/cXTwyGj47g== "@types/webpack-sources@*": version "0.1.5"