mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-28 04:23:32 +01:00
Support performing a js/ts workspace symbol search when focused on the left side of a git view
Fixes #75107
This commit is contained in:
@@ -9,13 +9,14 @@ import * as nls from 'vscode-nls';
|
||||
import * as Proto from '../protocol';
|
||||
import { ITypeScriptServiceClient } from '../typescriptService';
|
||||
import API from '../utils/api';
|
||||
import { Delayer } from '../utils/async';
|
||||
import { nulToken } from '../utils/cancellation';
|
||||
import { VersionDependentRegistration } from '../utils/dependentRegistration';
|
||||
import { Disposable } from '../utils/dispose';
|
||||
import * as fileSchemes from '../utils/fileSchemes';
|
||||
import { doesResourceLookLikeATypeScriptFile } from '../utils/languageDescription';
|
||||
import * as typeConverters from '../utils/typeConverters';
|
||||
import FileConfigurationManager from './fileConfigurationManager';
|
||||
import { Delayer } from '../utils/async';
|
||||
|
||||
const localize = nls.loadMessageBundle();
|
||||
|
||||
@@ -43,10 +44,6 @@ interface RenameAction {
|
||||
readonly jsTsFileThatIsBeingMoved: vscode.Uri;
|
||||
}
|
||||
|
||||
function doesResourceLookLikeATypeScriptFile(resource: vscode.Uri): boolean {
|
||||
return /\.tsx?$/i.test(resource.fsPath);
|
||||
}
|
||||
|
||||
class UpdateImportsOnFileRenameHandler extends Disposable {
|
||||
public static readonly minVersion = API.v300;
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
import * as vscode from 'vscode';
|
||||
import * as Proto from '../protocol';
|
||||
import { ITypeScriptServiceClient } from '../typescriptService';
|
||||
import * as fileSchemes from '../utils/fileSchemes';
|
||||
import { doesResourceLookLikeAJavaScriptFile, doesResourceLookLikeATypeScriptFile } from '../utils/languageDescription';
|
||||
import * as typeConverters from '../utils/typeConverters';
|
||||
|
||||
function getSymbolKind(item: Proto.NavtoItem): vscode.SymbolKind {
|
||||
@@ -35,7 +37,7 @@ class TypeScriptWorkspaceSymbolProvider implements vscode.WorkspaceSymbolProvide
|
||||
return [];
|
||||
}
|
||||
|
||||
const filepath = this.client.toOpenedFilePath(document);
|
||||
const filepath = await this.toOpenedFiledPath(document);
|
||||
if (!filepath) {
|
||||
return [];
|
||||
}
|
||||
@@ -62,10 +64,25 @@ class TypeScriptWorkspaceSymbolProvider implements vscode.WorkspaceSymbolProvide
|
||||
return result;
|
||||
}
|
||||
|
||||
private async toOpenedFiledPath(document: vscode.TextDocument) {
|
||||
if (document.uri.scheme === fileSchemes.git) {
|
||||
try {
|
||||
const path = vscode.Uri.file(JSON.parse(document.uri.query)?.path);
|
||||
if (doesResourceLookLikeATypeScriptFile(path) || doesResourceLookLikeAJavaScriptFile(path)) {
|
||||
const document = await vscode.workspace.openTextDocument(path);
|
||||
return this.client.toOpenedFilePath(document);
|
||||
}
|
||||
} catch {
|
||||
// noop
|
||||
}
|
||||
}
|
||||
return this.client.toOpenedFilePath(document);
|
||||
}
|
||||
|
||||
private static getLabel(item: Proto.NavtoItem) {
|
||||
let label = item.name;
|
||||
const label = item.name;
|
||||
if (item.kind === 'method' || item.kind === 'function') {
|
||||
label += '()';
|
||||
return label + '()';
|
||||
}
|
||||
return label;
|
||||
}
|
||||
@@ -97,4 +114,4 @@ export function register(
|
||||
modeIds: string[],
|
||||
) {
|
||||
return vscode.languages.registerWorkspaceSymbolProvider(new TypeScriptWorkspaceSymbolProvider(client, modeIds));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,8 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
export const file = 'file';
|
||||
|
||||
export const untitled = 'untitled';
|
||||
|
||||
export const git = 'git';
|
||||
export const walkThroughSnippet = 'walkThroughSnippet';
|
||||
|
||||
export const supportedSchemes = [
|
||||
@@ -17,4 +16,4 @@ export const supportedSchemes = [
|
||||
|
||||
export function isSupportedScheme(scheme: string): boolean {
|
||||
return supportedSchemes.indexOf(scheme) >= 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { basename } from 'path';
|
||||
import * as vscode from 'vscode';
|
||||
import * as languageModeIds from './languageModeIds';
|
||||
|
||||
export const enum DiagnosticLanguage {
|
||||
@@ -48,3 +49,11 @@ export function isTsConfigFileName(fileName: string): boolean {
|
||||
export function isJsConfigOrTsConfigFileName(fileName: string): boolean {
|
||||
return /^[jt]sconfig\.(.+\.)?json$/i.test(basename(fileName));
|
||||
}
|
||||
|
||||
export function doesResourceLookLikeATypeScriptFile(resource: vscode.Uri): boolean {
|
||||
return /\.tsx?$/i.test(resource.fsPath);
|
||||
}
|
||||
|
||||
export function doesResourceLookLikeAJavaScriptFile(resource: vscode.Uri): boolean {
|
||||
return /\.jsx?$/i.test(resource.fsPath);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user