Skip to content

Remove unused off-screen modification protection #1035

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 0 additions & 46 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,52 +42,6 @@ export async function activate(context: vscode.ExtensionContext) {
// TODO: Do this using the graph once we migrate its dependencies onto the graph
new CommandRunner(graph, thatMark, sourceMark);

// Disabled for now.
// See https://github.com/cursorless-dev/cursorless/issues/320
// vscode.workspace.onDidChangeTextDocument(checkForEditsOutsideViewport)
function _checkForEditsOutsideViewport(
event: vscode.TextDocumentChangeEvent
) {
// TODO: Only activate this code during the course of a cursorless action
// Can register pre/post command hooks the way we do with test case recorder
// TODO: Move this thing to a graph component
// TODO: Need to move command executor and test case recorder to graph
// component while we're doing this stuff so it's easier to register the
// hooks
// TODO: Should run this code even if document is not in a visible editor
// as long as we are during the course of a cursorless command.
const editor = vscode.window.activeTextEditor;

if (
editor == null ||
editor.document !== event.document ||
event.reason === vscode.TextDocumentChangeReason.Undo ||
event.reason === vscode.TextDocumentChangeReason.Redo
) {
return;
}

const ranges = event.contentChanges
.filter(
(contentChange) =>
!editor.visibleRanges.some(
(visibleRange) =>
contentChange.range.intersection(visibleRange) != null
)
)
.map(({ range }) => range);

if (ranges.length > 0) {
ranges.sort((a, b) => a.start.line - b.start.line);
const linesText = ranges
.map((range) => `${range.start.line + 1}-${range.end.line + 1}`)
.join(", ");
vscode.window.showWarningMessage(
`Modification outside of viewport at lines: ${linesText}`
);
}
}

return {
thatMark,
sourceMark,
Expand Down