File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -42,7 +42,10 @@ interface Props {
42
42
lang: Language
43
43
theme: string
44
44
fragments: boolean
45
+ fragmentIndex: number
46
+ snippetId: string
45
47
modelValue: string
48
+ isSearchMode: boolean
46
49
}
47
50
48
51
interface Emits {
@@ -151,6 +154,15 @@ const setTheme = () => {
151
154
editor .session .setMode (` ace/theme/${props .theme } ` )
152
155
}
153
156
157
+ const resetUndoStack = () => {
158
+ editor .getSession ().setUndoManager (new ace .UndoManager ())
159
+ }
160
+
161
+ const setCursorToStartAndClearSelection = () => {
162
+ editor .moveCursorTo (0 , 0 )
163
+ editor .clearSelection ()
164
+ }
165
+
154
166
const findAll = (q : string ) => {
155
167
if (q === ' ' ) return
156
168
editor .findAll (q , { caseSensitive: false , preventScroll: true })
@@ -182,6 +194,16 @@ watch(
182
194
}
183
195
)
184
196
197
+ watch (
198
+ () => [props .snippetId , props .fragmentIndex ],
199
+ () => {
200
+ resetUndoStack ()
201
+ if (! props .isSearchMode ) {
202
+ setCursorToStartAndClearSelection ()
203
+ }
204
+ }
205
+ )
206
+
185
207
window .addEventListener (' resize' , () => {
186
208
forceRefresh .value = Math .random ()
187
209
})
Original file line number Diff line number Diff line change 10
10
<TheEditor
11
11
v-model =" snippet"
12
12
v-model:lang =" lang"
13
+ :snippet-id =" snippetStore.selectedId!"
14
+ :fragment-index =" snippetStore.fragment"
15
+ :is-search-mode =" snippetStore.searchQuery?.length > 0"
13
16
:fragments =" snippetStore.isFragmentsShow"
14
17
/>
15
18
</template >
16
-
17
19
<div
18
20
v-else-if =" isShowPlaceholder"
19
21
class =" placeholder"
You can’t perform that action at this time.
0 commit comments