forked from goplus/builder
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Stop using monaco content-widget for In-editor overlay optimization
- Loading branch information
Showing
21 changed files
with
411 additions
and
287 deletions.
There are no files selected for viewing
9 changes: 1 addition & 8 deletions
9
spx-gui/src/components/editor/code-editor/ui/CodeEditorCard.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 38 additions & 3 deletions
41
spx-gui/src/components/editor/code-editor/ui/completion/CompletionUI.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,55 @@ | ||
<script setup lang="ts"> | ||
import { ref, watchEffect } from 'vue' | ||
import { UIDropdown, type DropdownPos } from '@/components/ui' | ||
import { toAbsolutePosition } from '../common' | ||
import { useCodeEditorUICtx } from '../CodeEditorUI.vue' | ||
import type { CompletionController } from '.' | ||
import CompletionCard from './CompletionCard.vue' | ||
defineProps<{ | ||
const props = defineProps<{ | ||
controller: CompletionController | ||
}>() | ||
const codeEditorUICtx = useCodeEditorUICtx() | ||
const dropdownVisible = ref(false) | ||
const dropdownPos = ref<DropdownPos>({ x: 0, y: 0 }) | ||
watchEffect(() => { | ||
const { currentCompletion, nonEmptyItems } = props.controller | ||
if (currentCompletion == null || nonEmptyItems == null) { | ||
dropdownVisible.value = false | ||
return | ||
} | ||
const aPos = toAbsolutePosition(currentCompletion.position, codeEditorUICtx.ui.editor) | ||
if (aPos == null) { | ||
dropdownVisible.value = false | ||
return | ||
} | ||
dropdownVisible.value = true | ||
dropdownPos.value = { | ||
x: aPos.left, | ||
y: aPos.top, | ||
width: 0, | ||
height: aPos.height | ||
} | ||
}) | ||
</script> | ||
|
||
<template> | ||
<Teleport :to="controller.widgetEl"> | ||
<UIDropdown | ||
:visible="dropdownVisible" | ||
trigger="manual" | ||
:pos="dropdownPos" | ||
placement="bottom-start" | ||
:offset="{ x: 0, y: 4 }" | ||
> | ||
<CompletionCard | ||
v-if="controller.nonEmptyItems != null" | ||
:items="controller.nonEmptyItems" | ||
:controller="controller" | ||
/> | ||
</Teleport> | ||
</UIDropdown> | ||
</template> | ||
|
||
<style lang="scss" scoped></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 38 additions & 3 deletions
41
spx-gui/src/components/editor/code-editor/ui/hover/HoverUI.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,55 @@ | ||
<script setup lang="ts"> | ||
import { ref, watchEffect } from 'vue' | ||
import { UIDropdown, type DropdownPos } from '@/components/ui' | ||
import { toAbsolutePosition } from '../common' | ||
import { useCodeEditorUICtx } from '../CodeEditorUI.vue' | ||
import type { HoverController } from '.' | ||
import HoverCard from './HoverCard.vue' | ||
defineProps<{ | ||
const props = defineProps<{ | ||
controller: HoverController | ||
}>() | ||
const codeEditorUICtx = useCodeEditorUICtx() | ||
const dropdownVisible = ref(false) | ||
const dropdownPos = ref<DropdownPos>({ x: 0, y: 0 }) | ||
watchEffect(() => { | ||
const hover = props.controller.currentHoverRef.value | ||
if (hover == null) { | ||
dropdownVisible.value = false | ||
return | ||
} | ||
const aPos = toAbsolutePosition(hover.range.start, codeEditorUICtx.ui.editor) | ||
if (aPos == null) { | ||
dropdownVisible.value = false | ||
return | ||
} | ||
dropdownVisible.value = true | ||
dropdownPos.value = { | ||
x: aPos.left, | ||
y: aPos.top, | ||
width: 0, | ||
height: aPos.height | ||
} | ||
}) | ||
</script> | ||
|
||
<template> | ||
<Teleport :to="controller.widgetEl"> | ||
<UIDropdown | ||
:visible="dropdownVisible" | ||
trigger="manual" | ||
:pos="dropdownPos" | ||
placement="top-start" | ||
:offset="{ x: 0, y: 4 }" | ||
> | ||
<HoverCard | ||
v-if="controller.currentHoverRef.value != null" | ||
:hover="controller.currentHoverRef.value" | ||
:controller="controller" | ||
/> | ||
</Teleport> | ||
</UIDropdown> | ||
</template> | ||
|
||
<style lang="scss" scoped></style> |
Oops, something went wrong.