Skip to content

Commit ae28c22

Browse files
committed
Merge branch 'main' into HEAD
2 parents e3d8249 + f2d955b commit ae28c22

File tree

1,351 files changed

+84744
-7422
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,351 files changed

+84744
-7422
lines changed

_extension/src/commands.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as vscode from "vscode";
22
import { Client } from "./client";
3+
import { restartExtHostOnChangeIfNeeded } from "./util";
34

45
export function registerEnablementCommands(context: vscode.ExtensionContext): void {
56
context.subscriptions.push(vscode.commands.registerCommand("typescript.native-preview.enable", () => {
@@ -50,7 +51,7 @@ async function updateUseTsgoSetting(enable: boolean): Promise<void> {
5051
}
5152
// Update the setting and restart the extension host (needed to change the state of the built-in TS extension)
5253
await tsConfig.update("experimental.useTsgo", enable, target);
53-
await vscode.commands.executeCommand("workbench.action.restartExtensionHost");
54+
await restartExtHostOnChangeIfNeeded();
5455
}
5556

5657
/**

_extension/src/extension.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
registerLanguageCommands,
77
} from "./commands";
88
import { setupStatusBar } from "./statusBar";
9+
import { needsExtHostRestartOnChange } from "./util";
910
import { setupVersionStatusItem } from "./versionStatusItem";
1011

1112
export async function activate(context: vscode.ExtensionContext) {
@@ -15,14 +16,11 @@ export async function activate(context: vscode.ExtensionContext) {
1516
const traceOutput = vscode.window.createOutputChannel("typescript-native-preview (LSP)");
1617
context.subscriptions.push(output, traceOutput);
1718

18-
const majorVersion = parseInt(vscode.version.split(".")[0]);
19-
const minorVersion = parseInt(vscode.version.split(".")[1]);
20-
const needsExtHostRestartOnChange = majorVersion <= 1 && minorVersion < 105;
2119
let disposeLanguageFeatures: vscode.Disposable | undefined;
2220

2321
context.subscriptions.push(vscode.workspace.onDidChangeConfiguration(async event => {
2422
if (event.affectsConfiguration("typescript.experimental.useTsgo")) {
25-
if (needsExtHostRestartOnChange) {
23+
if (needsExtHostRestartOnChange()) {
2624
// Delay because the command to change the config setting will restart
2725
// the extension host, so no need to show a message
2826
setTimeout(async () => {

_extension/src/util.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,15 @@ export function getLanguageForUri(uri: vscode.Uri): string | undefined {
8989
return undefined;
9090
}
9191
}
92+
93+
export function needsExtHostRestartOnChange() {
94+
const majorVersion = parseInt(vscode.version.split(".")[0]);
95+
const minorVersion = parseInt(vscode.version.split(".")[1]);
96+
return majorVersion <= 1 && minorVersion < 105;
97+
}
98+
99+
export async function restartExtHostOnChangeIfNeeded(): Promise<void> {
100+
if (needsExtHostRestartOnChange()) {
101+
await vscode.commands.executeCommand("workbench.action.restartExtensionHost");
102+
}
103+
}

_submodules/TypeScript

Submodule TypeScript updated 1509 files

internal/ast/ast.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10724,10 +10724,10 @@ type SourceFile struct {
1072410724
ClassifiableNames collections.Set[string]
1072510725
PatternAmbientModules []*PatternAmbientModule
1072610726

10727-
// Fields set by LineMap
10727+
// Fields set by ECMALineMap
1072810728

10729-
lineMapMu sync.RWMutex
10730-
lineMap []core.TextPos
10729+
ecmaLineMapMu sync.RWMutex
10730+
ecmaLineMap []core.TextPos
1073110731

1073210732
// Fields set by language service
1073310733

@@ -10862,17 +10862,17 @@ func (f *NodeFactory) UpdateSourceFile(node *SourceFile, statements *StatementLi
1086210862
return node.AsNode()
1086310863
}
1086410864

10865-
func (node *SourceFile) LineMap() []core.TextPos {
10866-
node.lineMapMu.RLock()
10867-
lineMap := node.lineMap
10868-
node.lineMapMu.RUnlock()
10865+
func (node *SourceFile) ECMALineMap() []core.TextPos {
10866+
node.ecmaLineMapMu.RLock()
10867+
lineMap := node.ecmaLineMap
10868+
node.ecmaLineMapMu.RUnlock()
1086910869
if lineMap == nil {
10870-
node.lineMapMu.Lock()
10871-
defer node.lineMapMu.Unlock()
10872-
lineMap = node.lineMap
10870+
node.ecmaLineMapMu.Lock()
10871+
defer node.ecmaLineMapMu.Unlock()
10872+
lineMap = node.ecmaLineMap
1087310873
if lineMap == nil {
10874-
lineMap = core.ComputeLineStarts(node.Text())
10875-
node.lineMap = lineMap
10874+
lineMap = core.ComputeECMALineStarts(node.Text())
10875+
node.ecmaLineMap = lineMap
1087610876
}
1087710877
}
1087810878
return lineMap
@@ -11054,7 +11054,7 @@ func getDeclarationName(declaration *Node) string {
1105411054

1105511055
type SourceFileLike interface {
1105611056
Text() string
11057-
LineMap() []core.TextPos
11057+
ECMALineMap() []core.TextPos
1105811058
}
1105911059

1106011060
type CommentRange struct {

internal/astnav/tokens_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ func tsGetTouchingPropertyName(t testing.TB, fileText string, positions []int) [
240240
}
241241

242242
func writeRangeDiff(output *strings.Builder, file *ast.SourceFile, diff tokenDiff, rng core.TextRange, position int) {
243-
lines := file.LineMap()
243+
lines := file.ECMALineMap()
244244

245245
tsTokenPos := position
246246
goTokenPos := position

internal/bundled/embed_generated.go

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)