From 4bf9699f266191627f85253d366daed02a241295 Mon Sep 17 00:00:00 2001 From: Peter Bartha Date: Tue, 21 Nov 2017 19:56:38 +0100 Subject: [PATCH] Add optional 'options' parameter to the setSelection and setSelections method in CodeMirror. --- types/codemirror/index.d.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/types/codemirror/index.d.ts b/types/codemirror/index.d.ts index 45e503e068..24e905b8e2 100644 --- a/types/codemirror/index.d.ts +++ b/types/codemirror/index.d.ts @@ -535,11 +535,14 @@ declare namespace CodeMirror { /** Set the cursor position.You can either pass a single { line , ch } object , or the line and the character as two separate parameters. */ setCursor(pos: CodeMirror.Position): void; - /** Set the selection range.anchor and head should be { line , ch } objects.head defaults to anchor when not given. */ - setSelection(anchor: CodeMirror.Position, head: CodeMirror.Position): void; + /** Set a single selection range. anchor and head should be {line, ch} objects. head defaults to anchor when not given. */ + setSelection(anchor: CodeMirror.Position, head: CodeMirror.Position, options?: { bias: number, clearRedo: boolean, origin: string, scroll: boolean }): void; - /** Set and normalize selection ranges and range should be { anchor, head } objects. primary determines which selection is the primary one. */ - setSelections(ranges: Array<{ anchor: CodeMirror.Position, head: CodeMirror.Position }>, primary?: number): void; + /** Sets a new set of selections. There must be at least one selection in the given array. When primary is a + number, it determines which selection is the primary one. When it is not given, the primary index is taken from + the previous selection, or set to the last range if the previous selection had less ranges than the new one. + Supports the same options as setSelection. */ + setSelections(ranges: Array<{ anchor: CodeMirror.Position, head: CodeMirror.Position }>, primary?: number, options?: { bias: number, clearRedo: boolean, origin: string, scroll: boolean }): void; /** Similar to setSelection , but will, if shift is held or the extending flag is set, move the head of the selection while leaving the anchor at its current place.