File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ /*---------------------------------------------------------------------------------------------
2+ * Copyright (c) Microsoft Corporation. All rights reserved.
3+ * Licensed under the MIT License. See License.txt in the project root for license information.
4+ *--------------------------------------------------------------------------------------------*/
5+
6+ import * as nls from 'vs/nls' ;
7+ import { ICodeEditor } from 'vs/editor/browser/editorBrowser' ;
8+ import { EditorAction , ServicesAccessor , registerEditorAction } from 'vs/editor/browser/editorExtensions' ;
9+ import { StopWatch } from 'vs/base/common/stopwatch' ;
10+
11+ class ForceRetokenizeAction extends EditorAction {
12+ constructor ( ) {
13+ super ( {
14+ id : 'editor.action.forceRetokenize' ,
15+ label : nls . localize ( 'forceRetokenize' , "Developer: Force Retokenize" ) ,
16+ alias : 'Developer: Force Retokenize' ,
17+ precondition : null
18+ } ) ;
19+ }
20+
21+ public run ( accessor : ServicesAccessor , editor : ICodeEditor ) : void {
22+ if ( ! editor . hasModel ( ) ) {
23+ return ;
24+ }
25+ const model = editor . getModel ( ) ;
26+ model . flushTokens ( ) ;
27+ const sw = new StopWatch ( true ) ;
28+ model . forceTokenization ( model . getLineCount ( ) ) ;
29+ sw . stop ( ) ;
30+ console . log ( `tokenization took ${ sw . elapsed ( ) } ` ) ;
31+ }
32+ }
33+
34+ registerEditorAction ( ForceRetokenizeAction ) ;
Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ import 'vs/editor/contrib/rename/rename';
3636import 'vs/editor/contrib/smartSelect/smartSelect' ;
3737import 'vs/editor/contrib/snippet/snippetController2' ;
3838import 'vs/editor/contrib/suggest/suggestController' ;
39+ import 'vs/editor/contrib/tokenization/tokenization' ;
3940import 'vs/editor/contrib/toggleTabFocusMode/toggleTabFocusMode' ;
4041import 'vs/editor/contrib/wordHighlighter/wordHighlighter' ;
4142import 'vs/editor/contrib/wordOperations/wordOperations' ;
You can’t perform that action at this time.
0 commit comments