Skip to content

Commit 44d6ab2

Browse files
bors[bot]matklad
andauthored
Merge #2697
2697: Restore internal applySourceChange command r=matklad a=matklad Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2 parents 09649a9 + 68b7d84 commit 44d6ab2

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

editors/code/src/commands/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as vscode from 'vscode';
22
import * as lc from 'vscode-languageclient';
33

44
import { Ctx, Cmd } from '../ctx';
5+
import * as sourceChange from '../source_change';
56

67
import { analyzerStatus } from './analyzer_status';
78
import { matchingBrace } from './matching_brace';
@@ -29,6 +30,12 @@ function showReferences(ctx: Ctx): Cmd {
2930
};
3031
}
3132

33+
function applySourceChange(ctx: Ctx): Cmd {
34+
return async (change: sourceChange.SourceChange) => {
35+
sourceChange.applySourceChange(ctx, change);
36+
}
37+
}
38+
3239
export {
3340
analyzerStatus,
3441
expandMacro,
@@ -41,4 +48,5 @@ export {
4148
run,
4249
runSingle,
4350
showReferences,
51+
applySourceChange,
4452
};

editors/code/src/highlighting.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@ const seedrandom = seedrandom_; // https://github.com/jvandemo/generator-angular
66
import * as scopes from './scopes';
77
import * as scopesMapper from './scopes_mapper';
88

9-
import { Server } from './server';
109
import { Ctx } from './ctx';
1110

1211
export function activateHighlighting(ctx: Ctx) {
13-
const highlighter = new Highlighter();
12+
const highlighter = new Highlighter(ctx);
1413

1514
ctx.client.onReady().then(() => {
1615
ctx.client.onNotification(
@@ -118,6 +117,12 @@ function createDecorationFromTextmate(
118117
}
119118

120119
class Highlighter {
120+
private ctx: Ctx;
121+
122+
constructor(ctx: Ctx) {
123+
this.ctx = ctx;
124+
}
125+
121126
private static initDecorations(): Map<
122127
string,
123128
vscode.TextEditorDecorationType
@@ -213,7 +218,7 @@ class Highlighter {
213218
string,
214219
[vscode.Range[], boolean]
215220
> = new Map();
216-
const rainbowTime = Server.config.rainbowHighlightingOn;
221+
const rainbowTime = this.ctx.config.rainbowHighlightingOn;
217222

218223
for (const tag of this.decorations.keys()) {
219224
byTag.set(tag, []);
@@ -232,13 +237,13 @@ class Highlighter {
232237
colorfulIdents
233238
.get(d.bindingHash)![0]
234239
.push(
235-
Server.client.protocol2CodeConverter.asRange(d.range),
240+
this.ctx.client.protocol2CodeConverter.asRange(d.range),
236241
);
237242
} else {
238243
byTag
239244
.get(d.tag)!
240245
.push(
241-
Server.client.protocol2CodeConverter.asRange(d.range),
246+
this.ctx.client.protocol2CodeConverter.asRange(d.range),
242247
);
243248
}
244249
}

editors/code/src/main.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export async function activate(context: vscode.ExtensionContext) {
2626
// Internal commands which are invoked by the server.
2727
ctx.registerCommand('runSingle', commands.runSingle);
2828
ctx.registerCommand('showReferences', commands.showReferences);
29+
ctx.registerCommand('applySourceChange', commands.applySourceChange);
2930

3031
if (ctx.config.enableEnhancedTyping) {
3132
ctx.overrideCommand('type', commands.onEnter);

0 commit comments

Comments
 (0)