diff options
-rw-r--r-- | editors/code/src/commands/index.ts | 8 | ||||
-rw-r--r-- | editors/code/src/highlighting.ts | 15 | ||||
-rw-r--r-- | editors/code/src/main.ts | 1 |
3 files changed, 19 insertions, 5 deletions
diff --git a/editors/code/src/commands/index.ts b/editors/code/src/commands/index.ts index 89af4be90..c28709c8a 100644 --- a/editors/code/src/commands/index.ts +++ b/editors/code/src/commands/index.ts | |||
@@ -2,6 +2,7 @@ import * as vscode from 'vscode'; | |||
2 | import * as lc from 'vscode-languageclient'; | 2 | import * as lc from 'vscode-languageclient'; |
3 | 3 | ||
4 | import { Ctx, Cmd } from '../ctx'; | 4 | import { Ctx, Cmd } from '../ctx'; |
5 | import * as sourceChange from '../source_change'; | ||
5 | 6 | ||
6 | import { analyzerStatus } from './analyzer_status'; | 7 | import { analyzerStatus } from './analyzer_status'; |
7 | import { matchingBrace } from './matching_brace'; | 8 | import { matchingBrace } from './matching_brace'; |
@@ -29,6 +30,12 @@ function showReferences(ctx: Ctx): Cmd { | |||
29 | }; | 30 | }; |
30 | } | 31 | } |
31 | 32 | ||
33 | function applySourceChange(ctx: Ctx): Cmd { | ||
34 | return async (change: sourceChange.SourceChange) => { | ||
35 | sourceChange.applySourceChange(ctx, change); | ||
36 | } | ||
37 | } | ||
38 | |||
32 | export { | 39 | export { |
33 | analyzerStatus, | 40 | analyzerStatus, |
34 | expandMacro, | 41 | expandMacro, |
@@ -41,4 +48,5 @@ export { | |||
41 | run, | 48 | run, |
42 | runSingle, | 49 | runSingle, |
43 | showReferences, | 50 | showReferences, |
51 | applySourceChange, | ||
44 | }; | 52 | }; |
diff --git a/editors/code/src/highlighting.ts b/editors/code/src/highlighting.ts index 96d550376..247673b5c 100644 --- a/editors/code/src/highlighting.ts +++ b/editors/code/src/highlighting.ts | |||
@@ -6,11 +6,10 @@ const seedrandom = seedrandom_; // https://github.com/jvandemo/generator-angular | |||
6 | import * as scopes from './scopes'; | 6 | import * as scopes from './scopes'; |
7 | import * as scopesMapper from './scopes_mapper'; | 7 | import * as scopesMapper from './scopes_mapper'; |
8 | 8 | ||
9 | import { Server } from './server'; | ||
10 | import { Ctx } from './ctx'; | 9 | import { Ctx } from './ctx'; |
11 | 10 | ||
12 | export function activateHighlighting(ctx: Ctx) { | 11 | export function activateHighlighting(ctx: Ctx) { |
13 | const highlighter = new Highlighter(); | 12 | const highlighter = new Highlighter(ctx); |
14 | 13 | ||
15 | ctx.client.onReady().then(() => { | 14 | ctx.client.onReady().then(() => { |
16 | ctx.client.onNotification( | 15 | ctx.client.onNotification( |
@@ -118,6 +117,12 @@ function createDecorationFromTextmate( | |||
118 | } | 117 | } |
119 | 118 | ||
120 | class Highlighter { | 119 | class Highlighter { |
120 | private ctx: Ctx; | ||
121 | |||
122 | constructor(ctx: Ctx) { | ||
123 | this.ctx = ctx; | ||
124 | } | ||
125 | |||
121 | private static initDecorations(): Map< | 126 | private static initDecorations(): Map< |
122 | string, | 127 | string, |
123 | vscode.TextEditorDecorationType | 128 | vscode.TextEditorDecorationType |
@@ -213,7 +218,7 @@ class Highlighter { | |||
213 | string, | 218 | string, |
214 | [vscode.Range[], boolean] | 219 | [vscode.Range[], boolean] |
215 | > = new Map(); | 220 | > = new Map(); |
216 | const rainbowTime = Server.config.rainbowHighlightingOn; | 221 | const rainbowTime = this.ctx.config.rainbowHighlightingOn; |
217 | 222 | ||
218 | for (const tag of this.decorations.keys()) { | 223 | for (const tag of this.decorations.keys()) { |
219 | byTag.set(tag, []); | 224 | byTag.set(tag, []); |
@@ -232,13 +237,13 @@ class Highlighter { | |||
232 | colorfulIdents | 237 | colorfulIdents |
233 | .get(d.bindingHash)![0] | 238 | .get(d.bindingHash)![0] |
234 | .push( | 239 | .push( |
235 | Server.client.protocol2CodeConverter.asRange(d.range), | 240 | this.ctx.client.protocol2CodeConverter.asRange(d.range), |
236 | ); | 241 | ); |
237 | } else { | 242 | } else { |
238 | byTag | 243 | byTag |
239 | .get(d.tag)! | 244 | .get(d.tag)! |
240 | .push( | 245 | .push( |
241 | Server.client.protocol2CodeConverter.asRange(d.range), | 246 | this.ctx.client.protocol2CodeConverter.asRange(d.range), |
242 | ); | 247 | ); |
243 | } | 248 | } |
244 | } | 249 | } |
diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts index 20a3ea119..0c4abdac8 100644 --- a/editors/code/src/main.ts +++ b/editors/code/src/main.ts | |||
@@ -26,6 +26,7 @@ export async function activate(context: vscode.ExtensionContext) { | |||
26 | // Internal commands which are invoked by the server. | 26 | // Internal commands which are invoked by the server. |
27 | ctx.registerCommand('runSingle', commands.runSingle); | 27 | ctx.registerCommand('runSingle', commands.runSingle); |
28 | ctx.registerCommand('showReferences', commands.showReferences); | 28 | ctx.registerCommand('showReferences', commands.showReferences); |
29 | ctx.registerCommand('applySourceChange', commands.applySourceChange); | ||
29 | 30 | ||
30 | if (ctx.config.enableEnhancedTyping) { | 31 | if (ctx.config.enableEnhancedTyping) { |
31 | ctx.overrideCommand('type', commands.onEnter); | 32 | ctx.overrideCommand('type', commands.onEnter); |