upd: display warning when word wrap dominated by long lines

This commit is contained in:
purocean
2022-01-02 22:47:44 +08:00
parent 0780a67dd2
commit 51ef65b535
+8 -1
View File
@@ -5,6 +5,7 @@ import { registerHook, triggerHook } from '@fe/core/hook'
import { registerAction } from '@fe/core/action'
import { Alt } from '@fe/core/command'
import store from '@fe/support/store'
import { useToast } from '@fe/support/ui/toast'
import { getColorScheme } from './theme'
import { getSetting } from './setting'
@@ -234,7 +235,13 @@ export function getSelectionInfo () {
* Toggle editor word wrap.
*/
export function toggleWrap () {
const isWrapping = getEditor().getOption(monaco.editor.EditorOption.wrappingInfo).isViewportWrapping
const wrapInfo = getEditor().getOption(monaco.editor.EditorOption.wrappingInfo)
const isWrapping = wrapInfo.isViewportWrapping
if (wrapInfo.isDominatedByLongLines) {
useToast().show('warning', 'Word warp dominated by long lines')
return
}
store.commit('setWordWrap', (isWrapping ? 'off' : 'on'))
}