diff --git a/packages/DomainCode-Diff/DCMatcher.class.st b/packages/DomainCode-Diff/DCMatcher.class.st index d32de22..c827bbc 100644 --- a/packages/DomainCode-Diff/DCMatcher.class.st +++ b/packages/DomainCode-Diff/DCMatcher.class.st @@ -46,13 +46,13 @@ DCMatcher >> fineGrainedMatch2From: src to: dest in: aMapping [ commonAncestorOf: (Array streamContents: [:s | dest allMorphsDo: [:k | (aMapping isDestMapped: k) ifFalse: [s nextPut: k]]]) root: dest. (topSrc notNil and: [topDest notNil]) ifTrue: [ - SBToggledCode - comment: '' - active: 0 - do: {[self assert: (aMapping destForSrc: topSrc owner) = topDest owner]}. - DCGreedyBottomUpMatcher new - sizeThreshold: 900000000; - lastChanceMatchFrom: topSrc to: topDest in: aMapping] + "see if we can answer quickly, otherwise we accept a worse diff result" + [ + DCGreedyBottomUpMatcher new + sizeThreshold: 900000000; + lastChanceMatchFrom: topSrc to: topDest in: aMapping] + valueWithin: 400 milliSeconds + onTimeout: []] ] { #category : #'as yet unclassified' } diff --git a/packages/DomainCode-Parser/DCBlock.class.st b/packages/DomainCode-Parser/DCBlock.class.st index 6fbc8e5..4555484 100644 --- a/packages/DomainCode-Parser/DCBlock.class.st +++ b/packages/DomainCode-Parser/DCBlock.class.st @@ -113,6 +113,17 @@ DCBlock class >> parseBlock: aString language: aLanguage [ yourself] ] +{ #category : #'as yet unclassified' } +DCBlock class >> registerShortcuts: aProvider [ + + aProvider cmdShortcut: $( do: #wrapInRoundParenthesis. + aProvider cmdShortcut: ${ do: #wrapInCurlyBraces. + aProvider cmdShortcut: $[ do: #wrapInSquareBrackets. + aProvider cmdShortcut: $' do: #wrapInSingleQuotes. + aProvider cmdShortcut: $" do: #wrapInDoubleQuotes. + aProvider cmdShortcut: $` do: #wrapInBackticks +] + { #category : #'as yet unclassified' } DCBlock >> absolutePositionOf: aMorph [ @@ -208,7 +219,7 @@ DCBlock >> deleteBeforeCursor [ do: [:new :edit | apply value: new value: edit value: cursorIndex - 1]] ] -{ #category : #'as yet unclassified' } +{ #category : #'text modify' } DCBlock >> deleteFrom: aString at: aNumber do: aBlock [ | new | @@ -403,7 +414,7 @@ DCBlock >> inputClosestTextMorphTo: cursorPosition [ in: best] ] -{ #category : #'as yet unclassified' } +{ #category : #'text modify' } DCBlock >> insert: aString in: aContainerString at: aNumber do: aBlock [ | new | @@ -556,8 +567,10 @@ DCBlock >> pairMap [ { #category : #'as yet unclassified' } DCBlock >> placeCursorIn: newTree at: newIndex [ + newIndex ifNil: [^ self]. + ^ newIndex isNumber ifTrue: [newTree startInputAtSourceIndex: newIndex] ifFalse: [ | target | - target := newTree blockFor: newIndex. + target := (newTree blockFor: newIndex) ifNil: [^ self]. target isTextMorph ifTrue: [ newTree sandblockEditor @@ -707,7 +720,7 @@ DCBlock >> swap: aNumber [ do: {[SBTSRange start: startIndex size: pivot range size]. [startIndex]})]]] ] -{ #category : #'as yet unclassified' } +{ #category : #'text modify' } DCBlock >> swap: aRange with: anotherRange in: aString do: aBlock [ | first second new | @@ -841,6 +854,69 @@ DCBlock >> valid [ ^ self type ~= 'ERROR' ] +{ #category : #'text modify' } +DCBlock >> wrap: aRange in: aString open: anotherString close: aThirdString [ + + self + example: [DCBlock new] + args: [{SBTSRange start: 3 size: 3. 'abcdefghi'. '('. ')'}] + label: 'example'. + + ^ (aString first: aRange start index), anotherString, (aString copyFrom: aRange start index + 1 to: aRange end index), aThirdString, (aString allButFirst: aRange end index) +] + +{ #category : #'action helpers' } +DCBlock >> wrapIn: aString [ + + ^ self tryApplyChange: [:source :textMorph :cursorIndex :apply | + apply + value: (self wrap: self range in: source open: aString close: (self pairMap at: aString)) + value: nil + value: self range] +] + +{ #category : #actions } +DCBlock >> wrapInBackticks [ + + + self wrapIn: '`' +] + +{ #category : #actions } +DCBlock >> wrapInCurlyBraces [ + + + self wrapIn: '{' +] + +{ #category : #actions } +DCBlock >> wrapInDoubleQuotes [ + + + self wrapIn: '"' +] + +{ #category : #actions } +DCBlock >> wrapInRoundParenthesis [ + + + self wrapIn: '(' +] + +{ #category : #actions } +DCBlock >> wrapInSingleQuotes [ + + + self wrapIn: '''' +] + +{ #category : #actions } +DCBlock >> wrapInSquareBrackets [ + + + self wrapIn: '[' +] + { #category : #'as yet unclassified' } DCBlock >> writeSourceOn: aStream [