a7285be3004088ad5dc27ee6e3357b92e66b9435825a31ea67a749fd927632249bd70292303ed547c1dbf9fc4a2726d10d00fda698257d6168cc4c1c7ccff7 1.3 KB

1234567891011121314151617181920212223242526272829
  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. import { StopWatch } from '../../../../base/common/stopwatch.js';
  6. import { EditorAction, registerEditorAction } from '../../../browser/editorExtensions.js';
  7. import * as nls from '../../../../nls.js';
  8. class ForceRetokenizeAction extends EditorAction {
  9. constructor() {
  10. super({
  11. id: 'editor.action.forceRetokenize',
  12. label: nls.localize('forceRetokenize', "Developer: Force Retokenize"),
  13. alias: 'Developer: Force Retokenize',
  14. precondition: undefined
  15. });
  16. }
  17. run(accessor, editor) {
  18. if (!editor.hasModel()) {
  19. return;
  20. }
  21. const model = editor.getModel();
  22. model.tokenization.resetTokenization();
  23. const sw = new StopWatch(true);
  24. model.tokenization.forceTokenization(model.getLineCount());
  25. sw.stop();
  26. console.log(`tokenization took ${sw.elapsed()}`);
  27. }
  28. }
  29. registerEditorAction(ForceRetokenizeAction);