Skip to content

Commit c8d8443

Browse files
fix(editor): height when opening code preview (#131)
1 parent c161c54 commit c8d8443

1 file changed

Lines changed: 24 additions & 1 deletion

File tree

src/renderer/components/editor/TheEditor.vue

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,15 @@
2828
</template>
2929

3030
<script setup lang="ts">
31-
import { computed, onMounted, onUnmounted, reactive, ref, watch } from 'vue'
31+
import {
32+
computed,
33+
nextTick,
34+
onMounted,
35+
onUnmounted,
36+
reactive,
37+
ref,
38+
watch
39+
} from 'vue'
3240
import type { Ace } from 'ace-builds'
3341
import ace from 'ace-builds'
3442
import './module-resolver'
@@ -281,6 +289,21 @@ watch(
281289
}
282290
)
283291
292+
watch(
293+
() => snippetStore.isCodePreview,
294+
() => {
295+
// Пока не нашел другого способа обновить высоту редактора в этом случае.
296+
// Странно то, что при ресайзе окна, высота редактора корректно высчитывается
297+
const scrollTop = editor.session.getScrollTop()
298+
299+
editor.destroy()
300+
nextTick(() => {
301+
init()
302+
editor.session.setScrollTop(scrollTop)
303+
})
304+
}
305+
)
306+
284307
emitter.on('snippet:format', () => format())
285308
286309
onUnmounted(() => {

0 commit comments

Comments
 (0)