Skip to content

Commit

Permalink
Optimize HistoryTracker using a cached TextDocument.version (#4681)
Browse files Browse the repository at this point in the history
This replaces `mightChangeDocument`, which sought to do the same sort of optimization in a less effective and far more clumsy way.
Fixes #4665
  • Loading branch information
J-Fields authored Mar 26, 2020
1 parent c4178b6 commit 824dda5
Show file tree
Hide file tree
Showing 13 changed files with 38 additions and 145 deletions.
5 changes: 0 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -918,11 +918,6 @@
"type": "boolean",
"markdownDescription": "When `true` the commands listed below move the cursor to the first non-blank of the line. When `false` the cursor is kept in the same column (if possible). This applies to the commands: `<C-d>`, `<C-u>`, `<C-b>`, `<C-f>`, `G`, `H`, `M`, `L`, `gg`, and to the commands `d`, `<<` and `>>` with a linewise operator.",
"default": true
},
"vim.experimentalOptimizations": {
"type": "boolean",
"description": "Increase performance of the extension, especially when navigating or editing large files. This is an experimental option and may cause unpredicted behaviour.",
"default": false
}
}
},
Expand Down
15 changes: 0 additions & 15 deletions src/actions/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,6 @@ export class BaseAction {
private static readonly isSingleNumber: RegExp = /^[0-9]$/;
private static readonly isSingleAlpha: RegExp = /^[a-zA-Z]$/;

/**
* True if this action has the potential to change the document's text, and therefore trigger an
* undo step. This is for optimization purposes - we skip the expensive process of figuring out
* what changed to create that undo step if this returns false.
*
* Most commands do not modify the document, so this is false by default. This means if you add a
* command that can modify the document or switch modes, you MUST set mightChangeDocument = true. Otherwise undo
* will not work properly.
*
*
* TODO: if all actions were pure, I think this would be unnecessary, as we could deduce it from
* vimState.transformations being empty or not.
*/
public mightChangeDocument: boolean = false;

/**
* Is this action valid in the current Vim state?
*/
Expand Down
Loading

0 comments on commit 824dda5

Please sign in to comment.