624
};
625
}
627
>
628
>
/**
629
>
* @internal
630
>
*/
631
>
export interface ITextModelCreationOptions {
632
>
tabSize: number;
633
>
indentSize: number | 'tabSize';
634
>
insertSpaces: boolean;
635
>
detectIndentation: boolean;
636
>
trimAutoWhitespace: boolean;
637
>
defaultEOL: DefaultEndOfLine;
638
>
isForSimpleWidget: boolean;
639
>
largeFileOptimizations: boolean;
640
>
bracketPairColorizationOptions: BracketPairColorizationOptions;
641
>
}
642
>
643
>
export interface BracketPairColorizationOptions {
644
>
enabled: boolean;
645
>
independentColorPoolPerBracketType: boolean;
646
>
}
647
>
648
>
export interface ITextModelUpdateOptions {
649
>
tabSize?: number;
650
>
indentSize?: number | 'tabSize';
651
>
insertSpaces?: boolean;
652
>
trimAutoWhitespace?: boolean;
653
>
bracketColorizationOptions?: BracketPairColorizationOptions;
654
>
}
655
>
656
>
export class FindMatch {
657
>
_findMatchBrand: void = undefined;
658
>
659
>
public readonly range: Range;
660
>
public readonly matches: string[] | null;
661
>
662
>
/**
663
>
* @internal
664
>
*/
665
>
constructor(range: Range, matches: string[] | null) {
666
this.range = range;
667
this.matches = matches;
668
}
670
>
671
>
/**
672
>
* Describes the behavior of decorations when typing/editing near their edges.
673
>
* Note: Please do not edit the values, as they very carefully match `DecorationRangeBehavior`
674
>
*/
675
>
export const enum TrackedRangeStickiness {
676
>
AlwaysGrowsWhenTypingAtEdges = 0,
677
>
NeverGrowsWhenTypingAtEdges = 1,
678
>
GrowsOnlyWhenTypingBefore = 2,
679
>
GrowsOnlyWhenTypingAfter = 3,
680
>
}
681
>
682
>
/**
683
>
* Text snapshot that works like an iterator.
684
>
* Will try to return chunks of roughly ~64KB size.
685
>
* Will return null when finished.
686
>
*/
687
>
export interface ITextSnapshot {
688
>
read(): string | null;
689
>
}
690
>
691
>
/**
692
>
* @internal
693
>
*/
694
>
export function isITextSnapshot(obj: unknown): obj is ITextSnapshot {
695
return (!!obj && typeof (obj as ITextSnapshot).read === 'function');
696
}
698
>
/**
699
>
* A model.
700
>
*/
701
>
export interface ITextModel {
702
>
703
>
/**
704
>
* Gets the resource associated with this editor model.
705
>
*/
706
>
readonly uri: URI;
707
>
708
>
/**
709
>
* A unique identifier associated with this model.
710
>
*/
711
>
readonly id: string;
712
>
713
>
/**
714
>
* This model is constructed for a simple widget code editor.
715
>
* @internal
716
>
*/
717
>
readonly isForSimpleWidget: boolean;
718
>
719
>
/**
720
>
* Method to register a view model on a model
721
>
* @internal
722
>
*/
723
>
registerViewModel(viewModel: IViewModel): void;
724
>
725
>
/**
726
>
* Method which unregister a view model on a model
727
>
* @internal
728
>
*/
729
>
unregisterViewModel(viewModel: IViewModel): void;
730
>
731
>
/**
732
>
* If true, the text model might contain RTL.
733
>
* If false, the text model **contains only** contain LTR.
734
>
* @internal
735
>
*/
736
>
mightContainRTL(): boolean;
737
>
738
>
/**
739
>
* If true, the text model might contain LINE SEPARATOR (LS), PARAGRAPH SEPARATOR (PS).
740
>
* If false, the text model definitely does not contain these.
741
>
* @internal
742
>
*/
743
>
mightContainUnusualLineTerminators(): boolean;
744
>
745
>
/**
746
>
* @internal
747
>
*/
748
>
removeUnusualLineTerminators(selections?: Selection[]): void;
749
>
750
>
/**
751
>
* If true, the text model might contain non basic ASCII.
752
>
* If false, the text model **contains only** basic ASCII.
753
>
* @internal
754
>
*/
755
>
mightContainNonBasicASCII(): boolean;
756
>
757
>
/**
758
>
* Get the resolved options for this model.
759
>
*/
760
>
getOptions(): TextModelResolvedOptions;
761
>
762
>
/**
763
>
* Get the formatting options for this model.
764
>
* @internal
765
>
*/
766
>
getFormattingOptions(): FormattingOptions;
767
>
768
>
/**
769
>
* Get the current version id of the model.
770
>
* Anytime a change happens to the model (even undo/redo),
771
>
* the version id is incremented.
772
>
*/
773
>
getVersionId(): number;
774
>
775
>
/**
776
>
* Get the alternative version id of the model.
777
>
* This alternative version id is not always incremented,
778
>
* it will return the same values in the case of undo-redo.
779
>
*/
780
>
getAlternativeVersionId(): number;
781
>
782
>
/**
783
>
* Replace the entire text buffer value contained in this model.
784
>
*/
785
>
setValue(newValue: string | ITextSnapshot): void;
786
>
787
>
/**
788
>
* Get the text stored in this model.
789
>
* @param eol The end of line character preference. Defaults to `EndOfLinePreference.TextDefined`.
790
>
* @param preserverBOM Preserve a BOM character if it was detected when the model was constructed.
791
>
* @return The text.
792
>
*/
793
>
getValue(eol?: EndOfLinePreference, preserveBOM?: boolean): string;
794
>
795
>
/**
796
>
* Get the text stored in this model.
797
>
* @param preserverBOM Preserve a BOM character if it was detected when the model was constructed.
798
>
* @return The text snapshot (it is safe to consume it asynchronously).
799
>
*/
800
>
createSnapshot(preserveBOM?: boolean): ITextSnapshot;
801
>
802
>
/**
803
>
* Get the length of the text stored in this model.
804
>
*/
805
>
getValueLength(eol?: EndOfLinePreference, preserveBOM?: boolean): number;
806
>
807
>
/**
808
>
* Check if the raw text stored in this model equals another raw text.
809
>
* @internal
810
>
*/
811
>
equalsTextBuffer(other: ITextBuffer): boolean;
812
>
813
>
/**
814
>
* Get the underling text buffer.
815
>
* @internal
816
>
*/
817
>
getTextBuffer(): ITextBuffer;
818
>
819
>
/**
820
>
* Get the text in a certain range.
821
>
* @param range The range describing what text to get.
822
>
* @param eol The end of line character preference. This will only be used for multiline ranges. Defaults to `EndOfLinePreference.TextDefined`.
823
>
* @return The text.
824
>
*/
825
>
getValueInRange(range: IRange, eol?: EndOfLinePreference): string;
826
>
827
>
/**
828
>
* Get the length of text in a certain range.
829
>
* @param range The range describing what text length to get.
830
>
* @return The text length.
831
>
*/
832
>
getValueLengthInRange(range: IRange, eol?: EndOfLinePreference): number;
833
>
834
>
/**
835
>
* Get the character count of text in a certain range.
836
>
* @param range The range describing what text length to get.
837
>
*/
838
>
getCharacterCountInRange(range: IRange, eol?: EndOfLinePreference): number;
839
>
840
>
/**
841
>
* Splits characters in two buckets. First bucket (A) is of characters that
842
>
* sit in lines with length < `LONG_LINE_BOUNDARY`. Second bucket (B) is of
843
>
* characters that sit in lines with length >= `LONG_LINE_BOUNDARY`.
844
>
* If count(B) > count(A) return true. Returns false otherwise.
845
>
* @internal
846
>
*/
847
>
isDominatedByLongLines(): boolean;
848
>
849
>
/**
850
>
* Get the number of lines in the model.
851
>
*/
852
>
getLineCount(): number;
853
>
854
>
/**
855
>
* Get the text for a certain line.
856
>
*/
857
>
getLineContent(lineNumber: number): string;
858
>
859
>
/**
860
>
* Get the line injected text for a certain line.
861
>
* @internal
862
>
*/
863
>
getLineInjectedText(lineNumber: number, ownerId?: number): LineInjectedText[];
864
>
865
>
/**
866
>
* Get the text length for a certain line.
867
>
*/
868
>
getLineLength(lineNumber: number): number;
869
>
870
>
/**
871
>
* Get the text for all lines.
872
>
*/
873
>
getLinesContent(): string[];
874
>
875
>
/**
876
>
* Get the end of line sequence predominantly used in the text buffer.
877
>
* @return EOL char sequence (e.g.: '\n' or '\r\n').
878
>
*/
879
>
getEOL(): string;
880
>
881
>
/**
882
>
* Get the end of line sequence predominantly used in the text buffer.
883
>
*/
884
>
getEndOfLineSequence(): EndOfLineSequence;
885
>
886
>
/**
887
>
* Get the minimum legal column for line at `lineNumber`
888
>
*/
889
>
getLineMinColumn(lineNumber: number): number;
890
>
891
>
/**
892
>
* Get the maximum legal column for line at `lineNumber`
893
>
*/
894
>
getLineMaxColumn(lineNumber: number): number;
895
>
896
>
/**
897
>
* Returns the column before the first non whitespace character for line at `lineNumber`.
898
>
* Returns 0 if line is empty or contains only whitespace.
899
>
*/
900
>
getLineFirstNonWhitespaceColumn(lineNumber: number): number;
901
>
902
>
/**
903
>
* Returns the column after the last non whitespace character for line at `lineNumber`.
904
>
* Returns 0 if line is empty or contains only whitespace.
905
>
*/
906
>
getLineLastNonWhitespaceColumn(lineNumber: number): number;
907
>
908
>
/**
909
>
* Create a valid position.
910
>
*/
911
>
validatePosition(position: IPosition): Position;
912
>
913
>
/**
914
>
* Advances the given position by the given offset (negative offsets are also accepted)
915
>
* and returns it as a new valid position.
916
>
*
917
>
* If the offset and position are such that their combination goes beyond the beginning or
918
>
* end of the model, throws an exception.
919
>
*
920
>
* If the offset is such that the new position would be in the middle of a multi-byte
921
>
* line terminator, throws an exception.
922
>
*/
923
>
modifyPosition(position: IPosition, offset: number): Position;
924
>
925
>
/**
926
>
* Create a valid range.
927
>
*/
928
>
validateRange(range: IRange): Range;
929
>
930
>
/**
931
>
* Verifies the range is valid.
932
>
*/
933
>
isValidRange(range: IRange): boolean;
934
>
935
>
/**
936
>
* Converts the position to a zero-based offset.
937
>
*
938
>
* The position will be [adjusted](#TextDocument.validatePosition).
939
>
*
940
>
* @param position A position.
941
>
* @return A valid zero-based offset.
942
>
*/
943
>
getOffsetAt(position: IPosition): number;
944
>
945
>
/**
946
>
* Converts a zero-based offset to a position.
947
>
*
948
>
* @param offset A zero-based offset.
949
>
* @return A valid [position](#Position).
950
>
*/
951
>
getPositionAt(offset: number): Position;
952
>
953
>
/**
954
>
* Get a range covering the entire model.
955
>
*/
956
>
getFullModelRange(): Range;
957
>
958
>
/**
959
>
* Returns if the model was disposed or not.
960
>
*/
961
>
isDisposed(): boolean;
962
>
963
>
/**
964
>
* This model is so large that it would not be a good idea to sync it over
965
>
* to web workers or other places.
966
>
* @internal
967
>
*/
968
>
isTooLargeForSyncing(): boolean;
969
>
970
>
/**
971
>
* The file is so large, that even tokenization is disabled.
972
>
* @internal
973
>
*/
974
>
isTooLargeForTokenization(): boolean;
975
>
976
>
/**
977
>
* The file is so large, that operations on it might be too large for heap
978
>
* and can lead to OOM crashes so they should be disabled.
979
>
* @internal
980
>
*/
981
>
isTooLargeForHeapOperation(): boolean;
982
>
983
>
/**
984
>
* Search the model.
985
>
* @param searchString The string used to search. If it is a regular expression, set `isRegex` to true.
986
>
* @param searchOnlyEditableRange Limit the searching to only search inside the editable range of the model.
987
>
* @param isRegex Used to indicate that `searchString` is a regular expression.
988
>
* @param matchCase Force the matching to match lower/upper case exactly.
989
>
* @param wordSeparators Force the matching to match entire words only. Pass null otherwise.
990
>
* @param captureMatches The result will contain the captured groups.
991
>
* @param limitResultCount Limit the number of results
992
>
* @return The ranges where the matches are. It is empty if not matches have been found.
993
>
*/
994
>
findMatches(searchString: string, searchOnlyEditableRange: boolean, isRegex: boolean, matchCase: boolean, wordSeparators: string | null, captureMatches: boolean, limitResultCount?: number): FindMatch[];
995
>
/**
996
>
* Search the model.
997
>
* @param searchString The string used to search. If it is a regular expression, set `isRegex` to true.
998
>
* @param searchScope Limit the searching to only search inside these ranges.
999
>
* @param isRegex Used to indicate that `searchString` is a regular expression.
1000
>
* @param matchCase Force the matching to match lower/upper case exactly.
1001
>
* @param wordSeparators Force the matching to match entire words only. Pass null otherwise.
1002
>
* @param captureMatches The result will contain the captured groups.
1003
>
* @param limitResultCount Limit the number of results
1004
>
* @return The ranges where the matches are. It is empty if no matches have been found.
1005
>
*/
1006
>
findMatches(searchString: string, searchScope: IRange | IRange[], isRegex: boolean, matchCase: boolean, wordSeparators: string | null, captureMatches: boolean, limitResultCount?: number): FindMatch[];
1007
>
/**
1008
>
* Search the model for the next match. Loops to the beginning of the model if needed.
1009
>
* @param searchString The string used to search. If it is a regular expression, set `isRegex` to true.
1010
>
* @param searchStart Start the searching at the specified position.
1011
>
* @param isRegex Used to indicate that `searchString` is a regular expression.
1012
>
* @param matchCase Force the matching to match lower/upper case exactly.
1013
>
* @param wordSeparators Force the matching to match entire words only. Pass null otherwise.
1014
>
* @param captureMatches The result will contain the captured groups.
1015
>
* @return The range where the next match is. It is null if no next match has been found.
1016
>
*/
1017
>
findNextMatch(searchString: string, searchStart: IPosition, isRegex: boolean, matchCase: boolean, wordSeparators: string | null, captureMatches: boolean): FindMatch | null;
1018
>
/**
1019
>
* Search the model for the previous match. Loops to the end of the model if needed.
1020
>
* @param searchString The string used to search. If it is a regular expression, set `isRegex` to true.
1021
>
* @param searchStart Start the searching at the specified position.
1022
>
* @param isRegex Used to indicate that `searchString` is a regular expression.
1023
>
* @param matchCase Force the matching to match lower/upper case exactly.
1024
>
* @param wordSeparators Force the matching to match entire words only. Pass null otherwise.
1025
>
* @param captureMatches The result will contain the captured groups.
1026
>
* @return The range where the previous match is. It is null if no previous match has been found.
1027
>
*/
1028
>
findPreviousMatch(searchString: string, searchStart: IPosition, isRegex: boolean, matchCase: boolean, wordSeparators: string | null, captureMatches: boolean): FindMatch | null;
1029
>
1030
>
1031
>
/**
1032
>
* Get the language associated with this model.
1033
>
*/
1034
>
getLanguageId(): string;
1035
>
1036
>
/**
1037
>
* Set the current language mode associated with the model.
1038
>
* @param languageId The new language.
1039
>
* @param source The source of the call that set the language.
1040
>
* @internal
1041
>
*/
1042
>
setLanguage(languageId: string, source?: string): void;
1043
>
1044
>
/**
1045
>
* Set the current language mode associated with the model.
1046
>
* @param languageSelection The new language selection.
1047
>
* @param source The source of the call that set the language.
1048
>
* @internal
1049
>
*/
1050
>
setLanguage(languageSelection: ILanguageSelection, source?: string): void;
1051
>
1052
>
/**
1053
>
* Returns the real (inner-most) language mode at a given position.
1054
>
* The result might be inaccurate. Use `forceTokenization` to ensure accurate tokens.
1055
>
* @internal
1056
>
*/
1057
>
getLanguageIdAtPosition(lineNumber: number, column: number): string;
1058
>
1059
>
/**
1060
>
* Get the word under or besides `position`.
1061
>
* @param position The position to look for a word.
1062
>
* @return The word under or besides `position`. Might be null.
1063
>
*/
1064
>
getWordAtPosition(position: IPosition): IWordAtPosition | null;
1065
>
1066
>
/**
1067
>
* Get the word under or besides `position` trimmed to `position`.column
1068
>
* @param position The position to look for a word.
1069
>
* @return The word under or besides `position`. Will never be null.
1070
>
*/
1071
>
getWordUntilPosition(position: IPosition): IWordAtPosition;
1072
>
1073
>
/**
1074
>
* Change the decorations. The callback will be called with a change accessor
1075
>
* that becomes invalid as soon as the callback finishes executing.
1076
>
* This allows for all events to be queued up until the change
1077
>
* is completed. Returns whatever the callback returns.
1078
>
* @param ownerId Identifies the editor id in which these decorations should appear. If no `ownerId` is provided, the decorations will appear in all editors that attach this model.
1079
>
* @internal
1080
>
*/
1081
>
changeDecorations<T>(callback: (changeAccessor: IModelDecorationsChangeAccessor) => T, ownerId?: number): T | null;
1082
>
1083
>
/**
1084
>
* Perform a minimum amount of operations, in order to transform the decorations
1085
>
* identified by `oldDecorations` to the decorations described by `newDecorations`
1086
>
* and returns the new identifiers associated with the resulting decorations.
1087
>
*
1088
>
* @param oldDecorations Array containing previous decorations identifiers.
1089
>
* @param newDecorations Array describing what decorations should result after the call.
1090
>
* @param ownerId Identifies the editor id in which these decorations should appear. If no `ownerId` is provided, the decorations will appear in all editors that attach this model.
1091
>
* @return An array containing the new decorations identifiers.
1092
>
*/
1093
>
deltaDecorations(oldDecorations: string[], newDecorations: IModelDeltaDecoration[], ownerId?: number): string[];
1094
>
1095
>
/**
1096
>
* Remove all decorations that have been added with this specific ownerId.
1097
>
* @param ownerId The owner id to search for.
1098
>
* @internal
1099
>
*/
1100
>
removeAllDecorationsWithOwnerId(ownerId: number): void;
1101
>
1102
>
/**
1103
>
* Get the options associated with a decoration.
1104
>
* @param id The decoration id.
1105
>
* @return The decoration options or null if the decoration was not found.
1106
>
*/
1107
>
getDecorationOptions(id: string): IModelDecorationOptions | null;
1108
>
1109
>
/**
1110
>
* Get the range associated with a decoration.
1111
>
* @param id The decoration id.
1112
>
* @return The decoration range or null if the decoration was not found.
1113
>
*/
1114
>
getDecorationRange(id: string): Range | null;
1115
>
1116
>
/**
1117
>
* Gets all the decorations for the line `lineNumber` as an array.
1118
>
* @param lineNumber The line number
1119
>
* @param ownerId If set, it will ignore decorations belonging to other owners.
1120
>
* @param filterOutValidation If set, it will ignore decorations specific to validation (i.e. warnings, errors).
1121
>
* @param filterFontDecorations If set, it will ignore font decorations.
1122
>
* @return An array with the decorations
1123
>
*/
1124
>
getLineDecorations(lineNumber: number, ownerId?: number, filterOutValidation?: boolean, filterFontDecorations?: boolean): IModelDecoration[];
1125
>
1126
>
/**
1127
>
* Gets all the font decorations for the line `lineNumber` as an array.
1128
>
* @param ownerId If set, it will ignore decorations belonging to other owners.
1129
>
* @internal
1130
>
*/
1131
>
getFontDecorationsInRange(range: IRange, ownerId?: number): IModelDecoration[];
1132
>
1133
>
/**
1134
>
* Gets all the decorations for the lines between `startLineNumber` and `endLineNumber` as an array.
1135
>
* @param startLineNumber The start line number
1136
>
* @param endLineNumber The end line number
1137
>
* @param ownerId If set, it will ignore decorations belonging to other owners.
1138
>
* @param filterOutValidation If set, it will ignore decorations specific to validation (i.e. warnings, errors).
1139
>
* @param filterFontDecorations If set, it will ignore font decorations.
1140
>
* @return An array with the decorations
1141
>
*/
1142
>
getLinesDecorations(startLineNumber: number, endLineNumber: number, ownerId?: number, filterOutValidation?: boolean, filterFontDecorations?: boolean): IModelDecoration[];
1143
>
1144
>
/**
1145
>
* Gets all the decorations in a range as an array. Only `startLineNumber` and `endLineNumber` from `range` are used for filtering.
1146
>
* So for now it returns all the decorations on the same line as `range`.
1147
>
* @param range The range to search in
1148
>
* @param ownerId If set, it will ignore decorations belonging to other owners.
1149
>
* @param filterOutValidation If set, it will ignore decorations specific to validation (i.e. warnings, errors).
1150
>
* @param filterFontDecorations If set, it will ignore font decorations.
1151
>
* @param onlyMinimapDecorations If set, it will return only decorations that render in the minimap.
1152
>
* @param onlyMarginDecorations If set, it will return only decorations that render in the glyph margin.
1153
>
* @return An array with the decorations
1154
>
*/
1155
>
getDecorationsInRange(range: IRange, ownerId?: number, filterOutValidation?: boolean, filterFontDecorations?: boolean, onlyMinimapDecorations?: boolean, onlyMarginDecorations?: boolean): IModelDecoration[];
1156
>
1157
>
/**
1158
>
* Gets all the decorations as an array.
1159
>
* @param ownerId If set, it will ignore decorations belonging to other owners.
1160
>
* @param filterOutValidation If set, it will ignore decorations specific to validation (i.e. warnings, errors).
1161
>
* @param filterFontDecorations If set, it will ignore font decorations.
1162
>
*/
1163
>
getAllDecorations(ownerId?: number, filterOutValidation?: boolean, filterFontDecorations?: boolean): IModelDecoration[];
1164
>
1165
>
/**
1166
>
* Gets all decorations that render in the glyph margin as an array.
1167
>
* @param ownerId If set, it will ignore decorations belonging to other owners.
1168
>
*/
1169
>
getAllMarginDecorations(ownerId?: number): IModelDecoration[];
1170
>
1171
>
/**
1172
>
* Gets all the decorations that should be rendered in the overview ruler as an array.
1173
>
* @param ownerId If set, it will ignore decorations belonging to other owners.
1174
>
* @param filterOutValidation If set, it will ignore decorations specific to validation (i.e. warnings, errors).
1175
>
* @param filterFontDecorations If set, it will ignore font decorations.
1176
>
*/
1177
>
getOverviewRulerDecorations(ownerId?: number, filterOutValidation?: boolean, filterFontDecorations?: boolean): IModelDecoration[];
1178
>
1179
>
/**
1180
>
* Gets all the decorations that contain injected text.
1181
>
* @param ownerId If set, it will ignore decorations belonging to other owners.
1182
>
*/
1183
>
getInjectedTextDecorations(ownerId?: number): IModelDecoration[];
1184
>
1185
>
/**
1186
>
* Gets all the decorations that contain custom line heights.
1187
>
* @param ownerId If set, it will ignore decorations belonging to other owners.
1188
>
*/
1189
>
getCustomLineHeightsDecorations(ownerId?: number): IModelDecoration[];
1190
>
1191
>
/**
1192
>
* Gets all the decorations that contain custom line heights.
1193
>
* @param range The range to search in
1194
>
* @param ownerId If set, it will ignore decorations belonging to other owners.
1195
>
*/
1196
>
getCustomLineHeightsDecorationsInRange(range: Range, ownerId?: number): IModelDecoration[];
1197
>
1198
>
/**
1199
>
* @internal
1200
>
*/
1201
>
_getTrackedRange(id: string): Range | null;
1202
>
1203
>
/**
1204
>
* @internal
1205
>
*/
1206
>
_setTrackedRange(id: string | null, newRange: null, newStickiness: TrackedRangeStickiness): null;
1207
>
/**
1208
>
* @internal
1209
>
*/
1210
>
_setTrackedRange(id: string | null, newRange: Range, newStickiness: TrackedRangeStickiness): string;
1211
>
1212
>
/**
1213
>
* Normalize a string containing whitespace according to indentation rules (converts to spaces or to tabs).
1214
>
*/
1215
>
normalizeIndentation(str: string): string;
1216
>
1217
>
/**
1218
>
* Change the options of this model.
1219
>
*/
1220
>
updateOptions(newOpts: ITextModelUpdateOptions): void;
1221
>
1222
>
/**
1223
>
* Detect the indentation options for this model from its content.
1224
>
*/
1225
>
detectIndentation(defaultInsertSpaces: boolean, defaultTabSize: number): void;
1226
>
1227
>
/**
1228
>
* Close the current undo-redo element.
1229
>
* This offers a way to create an undo/redo stop point.
1230
>
*/
1231
>
pushStackElement(): void;
1232
>
1233
>
/**
1234
>
* Open the current undo-redo element.
1235
>
* This offers a way to remove the current undo/redo stop point.
1236
>
*/
1237
>
popStackElement(): void;
1238
>
1239
>
/**
1240
>
* @internal
1241
>
*/
1242
>
edit(edit: TextEdit, options?: { reason?: TextModelEditSource }): void;
1243
>
1244
>
/**
1245
>
* Push edit operations, basically editing the model. This is the preferred way
1246
>
* of editing the model. The edit operations will land on the undo stack.
1247
>
* @param beforeCursorState The cursor state before the edit operations. This cursor state will be returned when `undo` or `redo` are invoked.
1248
>
* @param editOperations The edit operations.
1249
>
* @param cursorStateComputer A callback that can compute the resulting cursors state after the edit operations have been executed.
1250
>
* @return The cursor state returned by the `cursorStateComputer`.
1251
>
*/
1252
>
pushEditOperations(beforeCursorState: Selection[] | null, editOperations: IIdentifiedSingleEditOperation[], cursorStateComputer: ICursorStateComputer): Selection[] | null;
1253
>
/**
1254
>
* @internal
1255
>
*/
1256
>
pushEditOperations(beforeCursorState: Selection[] | null, editOperations: IIdentifiedSingleEditOperation[], cursorStateComputer: ICursorStateComputer, group?: UndoRedoGroup, reason?: TextModelEditSource): Selection[] | null;
1257
>
1258
>
/**
1259
>
* Change the end of line sequence. This is the preferred way of
1260
>
* changing the eol sequence. This will land on the undo stack.
1261
>
*/
1262
>
pushEOL(eol: EndOfLineSequence): void;
1263
>
1264
>
/**
1265
>
* Edit the model without adding the edits to the undo stack.
1266
>
* This can have dire consequences on the undo stack! See @pushEditOperations for the preferred way.
1267
>
* @param operations The edit operations.
1268
>
* @return If desired, the inverse edit operations, that, when applied, will bring the model back to the previous state.
1269
>
*/
1270
>
applyEdits(operations: readonly IIdentifiedSingleEditOperation[]): void;
1271
>
/** @internal */
1272
>
applyEdits(operations: readonly IIdentifiedSingleEditOperation[], reason: TextModelEditSource): void;
1273
>
applyEdits(operations: readonly IIdentifiedSingleEditOperation[], computeUndoEdits: false): void;
1274
>
applyEdits(operations: readonly IIdentifiedSingleEditOperation[], computeUndoEdits: true): IValidEditOperation[];
1275
>
1276
>
/**
1277
>
* Change the end of line sequence without recording in the undo stack.
1278
>
* This can have dire consequences on the undo stack! See @pushEOL for the preferred way.
1279
>
*/
1280
>
setEOL(eol: EndOfLineSequence): void;
1281
>
1282
>
/**
1283
>
* @internal
1284
>
*/
1285
>
_applyUndo(changes: TextChange[], eol: EndOfLineSequence, resultingAlternativeVersionId: number, resultingSelection: Selection[] | null): void;
1286
>
1287
>
/**
1288
>
* @internal
1289
>
*/
1290
>
_applyRedo(changes: TextChange[], eol: EndOfLineSequence, resultingAlternativeVersionId: number, resultingSelection: Selection[] | null): void;
1291
>
1292
>
/**
1293
>
* Undo edit operations until the previous undo/redo point.
1294
>
* The inverse edit operations will be pushed on the redo stack.
1295
>
*/
1296
>
undo(): void | Promise<void>;
1297
>
1298
>
/**
1299
>
* Is there anything in the undo stack?
1300
>
*/
1301
>
canUndo(): boolean;
1302
>
1303
>
/**
1304
>
* Redo edit operations until the next undo/redo point.
1305
>
* The inverse edit operations will be pushed on the undo stack.
1306
>
*/
1307
>
redo(): void | Promise<void>;
1308
>
1309
>
/**
1310
>
* Is there anything in the redo stack?
1311
>
*/
1312
>
canRedo(): boolean;
1313
>
1314
>
/**
1315
>
* An event emitted when the contents of the model have changed.
1316
>
* @event
1317
>
*/
1318
>
onDidChangeContent(listener: (e: IModelContentChangedEvent) => void): IDisposable;
1319
>
/**
1320
>
* An event emitted when decorations of the model have changed.
1321
>
* @event
1322
>
*/
1323
>
readonly onDidChangeDecorations: Event<IModelDecorationsChangedEvent>;
1324
>
/**
1325
>
* An event emitted when line heights from decorations changes.
1326
>
* This event is emitted only when adding, removing or changing a decoration
1327
>
* and not when doing edits in the model (i.e. when decoration ranges change)
1328
>
* @internal
1329
>
* @event
1330
>
*/
1331
>
readonly onDidChangeLineHeight: Event<ModelLineHeightChangedEvent>;
1332
>
/**
1333
>
* An event emitted when the font from decorations changes.
1334
>
* This event is emitted only when adding, removing or changing a decoration
1335
>
* and not when doing edits in the model (i.e. when decoration ranges change)
1336
>
* @internal
1337
>
* @event
1338
>
*/
1339
>
readonly onDidChangeFont: Event<ModelFontChangedEvent>;
1340
>
/**
1341
>
* An event emitted when the model options have changed.
1342
>
* @event
1343
>
*/
1344
>
readonly onDidChangeOptions: Event<IModelOptionsChangedEvent>;
1345
>
/**
1346
>
* An event emitted when the language associated with the model has changed.
1347
>
* @event
1348
>
*/
1349
>
readonly onDidChangeLanguage: Event<IModelLanguageChangedEvent>;
1350
>
/**
1351
>
* An event emitted when the language configuration associated with the model has changed.
1352
>
* @event
1353
>
*/
1354
>
readonly onDidChangeLanguageConfiguration: Event<IModelLanguageConfigurationChangedEvent>;
1355
>
/**
1356
>
* An event emitted when the tokens associated with the model have changed.
1357
>
* @event
1358
>
* @internal
1359
>
*/
1360
>
readonly onDidChangeTokens: Event<IModelTokensChangedEvent>;
1361
>
/**
1362
>
* An event emitted when the model has been attached to the first editor or detached from the last editor.
1363
>
* @event
1364
>
*/
1365
>
readonly onDidChangeAttached: Event<void>;
1366
>
/**
1367
>
* An event emitted right before disposing the model.
1368
>
* @event
1369
>
*/
1370
>
readonly onWillDispose: Event<void>;
1371
>
1372
>
/**
1373
>
* Destroy this model.
1374
>
*/
1375
>
dispose(): void;
1376
>
1377
>
/**
1378
>
* @internal
1379
>
*/
1380
>
onBeforeAttached(): IAttachedView;
1381
>
1382
>
/**
1383
>
* @internal
1384
>
*/
1385
>
onBeforeDetached(view: IAttachedView): void;
1386
>
1387
>
/**
1388
>
* Returns if this model is attached to an editor or not.
1389
>
*/
1390
>
isAttachedToEditor(): boolean;
1391
>
1392
>
/**
1393
>
* Returns the count of editors this model is attached to.
1394
>
* @internal
1395
>
*/
1396
>
getAttachedEditorCount(): number;
1397
>
1398
>
/**
1399
>
* Among all positions that are projected to the same position in the underlying text model as
1400
>
* the given position, select a unique position as indicated by the affinity.
1401
>
*
1402
>
* PositionAffinity.Left:
1403
>
* The normalized position must be equal or left to the requested position.
1404
>
*
1405
>
* PositionAffinity.Right:
1406
>
* The normalized position must be equal or right to the requested position.
1407
>
*
1408
>
* @internal
1409
>
*/
1410
>
normalizePosition(position: Position, affinity: PositionAffinity): Position;
1411
>
1412
>
/**
1413
>
* Gets the column at which indentation stops at a given line.
1414
>
* @internal
1415
>
*/
1416
>
getLineIndentColumn(lineNumber: number): number;
1417
>
1418
>
/**
1419
>
* Returns an object that can be used to query brackets.
1420
>
* @internal
1421
>
*/
1422
>
readonly bracketPairs: IBracketPairsTextModelPart;
1423
>
1424
>
/**
1425
>
* Returns an object that can be used to query indent guides.
1426
>
* @internal
1427
>
*/
1428
>
readonly guides: IGuidesTextModelPart;
1429
>
1430
>
/**
1431
>
* @internal
1432
>
*/
1433
>
readonly tokenization: ITokenizationTextModelPart;
1434
>
}
1435
>
1436
>
/**
1437
>
* @internal
1438
>
*/
1439
>
export function isITextModel(obj: IEditorModel): obj is ITextModel {
1440
return Boolean(obj && (obj as ITextModel).uri);
1441
}
1443
>
/**
1444
>
* @internal
1445
>
*/
1446
>
export interface IAttachedView {
1447
>
/**
1448
>
* @param stabilized Indicates if the visible lines are probably going to change soon or can be considered stable.
1449
>
* Is true on reveal range and false on scroll.
1450
>
* Tokenizers should tokenize synchronously if stabilized is true.
1451
>
*/
1452
>
setVisibleLines(visibleLines: { startLineNumber: number; endLineNumber: number }[], stabilized: boolean): void;
1453
>
}
1454
>
1455
>
export const enum PositionAffinity {
1456
>
/**
1457
>
* Prefers the left most position.
1458
>
*/
1459
>
Left = 0,
1460
>
1461
>
/**
1462
>
* Prefers the right most position.
1463
>
*/
1464
>
Right = 1,
1465
>
1466
>
/**
1467
>
* No preference.
1468
>
*/
1469
>
None = 2,
1470
>
1471
>
/**
1472
>
* If the given position is on injected text, prefers the position left of it.
1473
>
*/
1474
>
LeftOfInjectedText = 3,
1475
>
1476
>
/**
1477
>
* If the given position is on injected text, prefers the position right of it.
1478
>
*/
1479
>
RightOfInjectedText = 4,
1480
>
}
1481
>
1482
>
/**
1483
>
* @internal
1484
>
*/
1485
>
export interface ITextBufferBuilder {
1486
>
acceptChunk(chunk: string): void;
1487
>
finish(): ITextBufferFactory;
1488
>
}
1489
>
1490
>
/**
1491
>
* @internal
1492
>
*/
1493
>
export interface ITextBufferFactory {
1494
>
create(defaultEOL: DefaultEndOfLine): { textBuffer: ITextBuffer; disposable: IDisposable };
1495
>
getFirstLineText(lengthLimit: number): string;
1496
>
}
1497
>
1498
>
/**
1499
>
* @internal
1500
>
*/
1501
>
export const enum ModelConstants {
1502
>
FIRST_LINE_DETECTION_LENGTH_LIMIT = 1000
1503
>
}
1504
>
1505
>
/**
1506
>
* @internal
1507
>
*/
1508
>
export class ValidAnnotatedEditOperation implements IIdentifiedSingleEditOperation {
1509
>
constructor(
1510
public readonly identifier: ISingleEditOperationIdentifier | null,
1511
public readonly range: Range,