MCPcopy Create free account
hub / github.com/cursorless-dev/cursorless / displayPendingEditDecorations

Function displayPendingEditDecorations

src/util/editDisplayUtils.ts:48–98  ·  view source on GitHub ↗
(
  targets: TypedSelection[],
  editStyle: EditStyle
)

Source from the content-addressed store, hash-verified

46}
47
48export default async function displayPendingEditDecorations(
49 targets: TypedSelection[],
50 editStyle: EditStyle
51) {
52 await runOnTargetsForEachEditor(targets, async (editor, selections) => {
53 editor.setDecorations(
54 editStyle.token,
55 selections
56 .filter((selection) => !useLineDecorations(selection))
57 .map((selection) => selection.selection.selection)
58 );
59
60 editor.setDecorations(
61 editStyle.line,
62 selections
63 .filter((selection) => useLineDecorations(selection))
64 .map((selection) => {
65 const { document } = selection.selection.editor;
66 const { start, end } = selection.selection.selection;
67 const startLine = document.lineAt(start);
68 const hasLeadingLine =
69 start.character === startLine.range.end.character;
70 if (
71 end.character === 0 &&
72 (!hasLeadingLine || start.character === 0)
73 ) {
74 // NB: We move end up one line because it is at beginning of
75 // next line
76 return selection.selection.selection.with({
77 end: end.translate(-1),
78 });
79 }
80 if (hasLeadingLine) {
81 // NB: We move start down one line because it is at end of
82 // previous line
83 return selection.selection.selection.with({
84 start: start.translate(1),
85 });
86 }
87 return selection.selection.selection;
88 })
89 );
90 });
91
92 await decorationSleep();
93
94 await runOnTargetsForEachEditor(targets, async (editor) => {
95 editor.setDecorations(editStyle.token, []);
96 editor.setDecorations(editStyle.line, []);
97 });
98}
99
100function useLineDecorations(selection: TypedSelection) {
101 return (

Callers 10

runMethod · 0.85
runMethod · 0.85
runMethod · 0.85
runMethod · 0.85
runMethod · 0.85
runMethod · 0.85
runMethod · 0.85
runMethod · 0.85
decorateTargetsMethod · 0.85
decorateThatMarkMethod · 0.85

Calls 3

useLineDecorationsFunction · 0.85
decorationSleepFunction · 0.85

Tested by

no test coverage detected